Hisoft Colt Compiler and sprites

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
Jodo
Drutt
Posts: 25
Joined: Wed Apr 11, 2018 10:52 am
Location: West Yorkshire, UK

Hisoft Colt Compiler and sprites

Post by Jodo »

Having read PeterJ's thread on Hisoft Colt Compiler my interest was piqued by the mention of the sprite implementation.

My first game is coming along nicely and I would love to progress from character movement to pixel movement. The problem I have is that I would have two sprites, one of them interacting with collision detection via attribute checking on up to 130 character positions. (Yes, I wanted to try my hand at a retro game as a first project - Breakout it is! :D ) Is this cross-graphical use possible? Each brick as a sprite would seem wasteful even if possible and I think Colt's limit is 16 sprites anyway.

I've played around with Colt this evening and got a sprite moving around with screen edge detection working. It would be a vast improvement on what I currently have if it's possible.

Thanks!
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Hisoft Colt Compiler and sprites

Post by Morkin »

Don't know much about the compiler, but good luck with the game..! :)

If someone asked me to write a breakout game I'd probably do attribute checks for the collisions too (unless your bricks move about!) as you know where they are positioned on screen so you know where to check, draw and erase.

Pixel movement can be challenging, especially in BASIC..! You could always try 2 or 4 pixel movement, at speed it can still look perfectly smooth. Though it's your game so feel free to go with what you feel like doing. :)
My Speccy site: thirdharmoniser.com
User avatar
Cosmium
Microbot
Posts: 154
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: Hisoft Colt Compiler and sprites

Post by Cosmium »

Hi - don't know much about this compiler either, but I too would definitely be using attributes to check for a collision with this type of game. :)

So just after you've calculated the new ball position, use ATTR (assuming the compiler supports this BASIC command; if not you can use PEEK to obtain the attribute byte at the correct address) at the ball's new chr line and chr column position and see if it returns the colour of one of the blocks, signifying a collision. If you're storing the ball x and y as a pixel coordinate, you'll need to divide both by 8 to get the chr position.

Since in Breakout the blocks usually only appear above a certain line on screen, you only need to do this check if the ball's y is less than or equal to the lowest block.

Good luck with the game!
Jodo
Drutt
Posts: 25
Joined: Wed Apr 11, 2018 10:52 am
Location: West Yorkshire, UK

Re: Hisoft Colt Compiler and sprites

Post by Jodo »

Thanks for your input guys.

I had a good think about the interaction between the character blocks and the ball sprite last night and came to the same conclusion about dividing the ball pixel x,y coords by 8 to get the character position for ATTR checking so thanks for the validation of my thinking Cosmium!

I have already implemented the "check only above the blocks level" in the fully character based game but thanks for the idea. I have working power ups and power downs implemented (need a few more though) and hope to build another 30 or so levels on top of the 6 I have already for testing.

My main challenge now will be re-writing the collision detection. Unfortunately, BASinC obviously won't accept the new compiler only sprite commands so I'll have to switch to Notepad for editing and covert to .tap to get it into the compiler. There is absolutely no way I am going to do the re-writing in 48k Basic directly into the compiler, I'm not that much of a masochist. :lol: Something else to get my head around but I'm sure it will be worth the effort if I can complete it.
User avatar
Morkin
Bugaboo
Posts: 3251
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Hisoft Colt Compiler and sprites

Post by Morkin »

Didn't realise that some of these compilers had extra commands.

I thought they just... well... compiled..! :lol:
My Speccy site: thirdharmoniser.com
Jodo
Drutt
Posts: 25
Joined: Wed Apr 11, 2018 10:52 am
Location: West Yorkshire, UK

Re: Hisoft Colt Compiler and sprites

Post by Jodo »

Yeah, I was surprised too, Colt gets the Spectrum doing windows as well!

Even if Hisoft Colt works out to be a bit slower that Hisoft Basic I think it'll still be fast enough.

I've made the decision to carry on developing in BASinC for the time being as testing will be much easier (and quicker!) whilst I complete the rest of the game. I'll then at least have a game which can be compiled with Hisoft Basic and will be plenty fast enough, albeit with 8 pixel character movement. After that I'll move on to getting the sprites implemented, testing will be harder only for that last bit of development then.
Post Reply