Displaying my first sprite

Show us what you're working on, (preferably with screenshots).
User avatar
Pegaz
Dynamite Dan
Posts: 1210
Joined: Mon Nov 13, 2017 1:44 pm

Re: Displaying my first sprite

Post by Pegaz »

Freespirit wrote: Thu Jul 16, 2020 10:09 am
Pegaz wrote: Wed Jul 15, 2020 8:24 pm If you continue to progress like this, we won’t have to wait long for a new Sidewize. :)
I'd not heard of this one, had to look it up. Looks good. A standard to aim for.
There’s also its sequel Crosswize, with great animation and effects:

https://spectrumcomputing.co.uk/entry/1 ... /Crosswize
Freespirit
Microbot
Posts: 105
Joined: Wed Jul 01, 2020 2:33 pm

Re: Displaying my first sprite

Post by Freespirit »

Joefish wrote: Thu Jul 16, 2020 11:08 am
Freespirit wrote: Thu Jul 16, 2020 9:47 am Thanks Joefish, i just started using IX a few days ago, very handy. I didn't know about the ld a,-1 i just tried it and it compiles fine. Interesting. I will have to go through some examples and your explanation to get my head around the calculations. Its amazing all the little tricks you can do.
Yep, IX and IY are interesting. Their operations run a bit slower than the HL equivalents so most people start to use them when they run out of other registers. It's kind of a hidden feature of the Z80 but most compilers will let you use instructions that address 8-bit halves of IX and IY. So most things you can do with H and L separately, you can also do with IXH, IXL, IYH and IYL, e.g. LD IXL,1

They're also good for looking things up in a table. Like in my Pac-Man maze generator I can point IY at a cell in the table, then use LD A,(IY+1) to read the cell to the right, or (IY-32) to read the cell above.

And for structured data; for example, if your sprite data is always "1 byte for sprite ID, 1 for X, 1 for Y, 1 for Vx, 1 for Vy and 1 for HP remaining" then you can point IX at the first byte, then read (for example) the hit-points remaining on your sprite with LD A,(IX+5). That way all your functions that deal with sprites just need to be given that root IX value and they all know how to fetch the relevant data to do anything with any sprite.
Thanks for this, I didn’t know about IXL and IXH. Yes, I’m using it for a table exactly as you say for x,y etc. Strangely I used IX+1 a few days ago just to see if it would work and I’m now using it with the table.
Freespirit
Microbot
Posts: 105
Joined: Wed Jul 01, 2020 2:33 pm

Re: Displaying my first sprite

Post by Freespirit »

Pegaz wrote: Thu Jul 16, 2020 11:49 am There’s also its sequel Crosswize, with great animation and effects:

https://spectrumcomputing.co.uk/entry/1 ... /Crosswize
They really improved their game for the sequel it looks a lot better. Very impressive.
Freespirit
Microbot
Posts: 105
Joined: Wed Jul 01, 2020 2:33 pm

Re: Displaying my first sprite

Post by Freespirit »

Jetpac meets Flappy bird. It's the game 'Ultimate' always wanted to make.


Image
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Displaying my first sprite

Post by Ast A. Moore »

Very impressive. Horizontal scrollers are the hardest to code on the Spectrum.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
robdc
Drutt
Posts: 5
Joined: Fri Jul 10, 2020 2:32 pm

Re: Displaying my first sprite

Post by robdc »

Looking really cool [mention]Freespirit[/mention]
I'm in similar place as you, started learning Z80 assembly a few weeks ago, using flappy bird as my learning project coincidentally.
Will post a clip of my progress later
Freespirit
Microbot
Posts: 105
Joined: Wed Jul 01, 2020 2:33 pm

Re: Displaying my first sprite

Post by Freespirit »

Well, 'Jetflap' is complete (sort of). It's probably the greatest 10 second game ever (released today) and A LOT could be improved. It took me to my limits rather than the other way around. :D

https://1drv.ms/u/s!At9gHWg9x_GpjgiWn5T ... 1?e=6UPV3f
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Displaying my first sprite

Post by Ast A. Moore »

Could you also provide a regular TAP/TZX file please? (I generally avoid loading snapshot, because they mess up my emulator’s settings.)
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
dfzx
Manic Miner
Posts: 681
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Displaying my first sprite

Post by dfzx »

Freespirit wrote: Tue Jul 21, 2020 2:47 pm Well, 'Jetflap' is complete (sort of).
An extra point for the name, I think. :lol:
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
Freespirit
Microbot
Posts: 105
Joined: Wed Jul 01, 2020 2:33 pm

Re: Displaying my first sprite

Post by Freespirit »

User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Displaying my first sprite

Post by Ast A. Moore »

Freespirit wrote: Tue Jul 21, 2020 5:54 pm Here is the tzx version:

https://1drv.ms/u/s!At9gHWg9x_GpjguV18a ... b?e=APX6w4
Thanks!

The game looks great. Really good for a debut. If I could suggest one improvement that would have the greatest impact on playability, it would be the scroll rate. Right now, it’s inconsistent and speeds up and slows down unpredictably. Slowing down is fine, but speeding up leaves you no time to maneuver.

Other than that, you could implement a simple keyboard debounce routine upon entering the various menu and info screens. That way they won’t flick by when the game ends. One of the simples ways to do it is this:

Code: Select all

1$		call $28e		;poll keyboard upon entry
		inc e			;if E=FFh (no key is pressed), INC E will result in 0
		jr nz,1$		;and we can go on; else, we wait until no key is pressed
It’s sometimes a good idea to put this little check before your check for a valid keypress.

For example, after a player dies and the game ends, he normally keesp pressing one of the control keys (well, just the one in your case). If you then immediately display a game-over screen and wait for a keypress to dismiss it, it’ll disappear in the next frame, because the play will likely not have released the key in that short time. The code above will make sure that doesn’t happen.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Freespirit
Microbot
Posts: 105
Joined: Wed Jul 01, 2020 2:33 pm

Re: Displaying my first sprite

Post by Freespirit »

Thanks for the feedback. Yes, there are a few scroll speed issues. The keyboard routine will be very useful, thanks for that. :D
Post Reply