Writing my first (simple) game in assembly

Página 5/5
1 | 2 | 3 | 4 |

Por Pbk71

Expert (101)

Imagen del Pbk71

06-06-2021, 20:29

Little update for who is interested. I'm still working on my first game written in assembly. But at the moment all the programming is done in Notepad++ where I use multiple include files to keep an overview. I use Sjasm to create my bin-file.

I am cleaning up my code and transferring all routines to the 'real' game. Something I've added recently is an algorithm to create the obstacles in my buffer that I use to move the obstacles from right to left. There are 10 bufferlines. Each one starts with one 'extra' byte, 32 bytes to draw on screen and then 20 extra bytes 'off screen' to place the obstacle.

extrabyte1:	 		db 0
bufferline1: 			ds BUFFERWIDTH,32
extrabyte2:	 		db 0
bufferline2: 			ds BUFFERWIDTH,32
extrabyte3:	 		db 0
bufferline3: 			ds BUFFERWIDTH,32
extrabyte4:	 		db 0
bufferline4: 			ds BUFFERWIDTH,32
extrabyte5:	 		db 0
bufferline5: 			ds BUFFERWIDTH,32
extrabyte6:	 		db 0
bufferline6: 			ds BUFFERWIDTH,32
extrabyte7:	 		db 0
bufferline7: 			ds BUFFERWIDTH,32
extrabyte8:	 		db 0
bufferline8: 			ds BUFFERWIDTH,32
extrabyte9:	 		db 0
bufferline9: 			ds BUFFERWIDTH,32
extrabyte10:			db 0
bufferline10: 			ds BUFFERWIDTH,32

Now I've created a routine that reads a serie of bytes and converts them to an obstacle. The data for obstacles can look like this:

obstacle1_0:	db 0,212,0,212,53,9,10,255				 
obstacle1_1:	db 0,212,0,212,53,2,2,11,2,2,255 		  
obstacle1_2:	db 0,212,213,4,13,35,2,2,2,11,2,255
obstacle1_3:	db 0,212,228,2,35,4,11,2,2,255

The routine starts just before the first 'off screen' byte. It loads a byte, adds the value to the position and then places the right character there. A zero indicates that the next value will be added but there will be no character added. 255 indicates the end of the obstacle.

The actual routine looks like this:

; memory address of obstacle data is loaded in ix

; --- OBSTACLE CREATION ROUTINE ---
co_obstaclecreation:
	ld hl,bufferline1+31	        ; start at bufferline1 at the last visible character
	ld de,0x0000			; de is used to increase hl; d should be 0x00
			
co_createobstacleloop:
	ld a,(ix) 				; load the byte of the obstacle
        cp 255				; if value is 255...
        jp z,co_donecreatingobstacle
						; ...then done with creating the obstacle
	cp 0					; if value is 0...
	jp z, co_addnoobstacle	; ... then only add the value to hl, but don't place obstacle character
        ld e,a				; load value to add to hl in e
        add hl,de				; add de to hl 
        ld (hl),15				; place obstacle pattern in buffer
        inc ix					; next byte of obstacle data
        jp co_createobstacleloop
			
co_addnoobstacle:
	inc ix				; next byte of obstacle data 
	ld e,(ix)				; load value to add to hl in e
        add hl,de				; add de to hl
        inc ix				; next byte of obstacle data
        jp co_createobstacleloop 			        
            
co_donecreatingobstacle:				
	ret

Works very good. As soon as there is something I can show I will post it here.

Por Pbk71

Expert (101)

Imagen del Pbk71

16-06-2021, 16:32

It's been a while, but I've got a rough early playable version:

https://webmsx.org/?MACHINE=MSX1&DISK_FILES=https://leswiki.nl/msx_raj/raj.out&BASIC_BRUN=raj.out&FAST_BOOT

I have added 3 gamestates:

  1. Ready to start (press space to start the game)
  2. Game is running
  3. Game over (player falls off the wall, then back to state 1)

The game now is very simple. My basic framework works so the next thing I will do is to add more and different obstacles that move with different speeds. I'm going to use levels that increase according to the score (every 1000 points the game will change).

When that's done...

  • Create a decent, animated sprite for the player
  • Add some sound effects
  • Add an intro

I have to find some more time ;)

Por santiontanon

Paragon (1418)

Imagen del santiontanon

17-06-2021, 17:12

cool!! The current player sprite is from "Joust" right?

Por Pbk71

Expert (101)

Imagen del Pbk71

17-06-2021, 20:09

santiontanon wrote:

cool!! The current player sprite is from "Joust" right?

That's right Wink one of my favourite Atari 2600 games.
Just for testing only. I needed a sprite Wink

Por Pbk71

Expert (101)

Imagen del Pbk71

18-06-2021, 23:01

More work done. The player has an animated sprite now and if you reach 1000 points different obstacles will appear.
The new obstacles are way too difficult now. The game will get more balanced when it is finished, this is just to test if it works (and it does Smile )

Try it here.

Por JohnHassink

Ambassador (5575)

Imagen del JohnHassink

19-06-2021, 02:26

Plays really responsive and intuitive, and really nice smooth scrolling!

Por santiontanon

Paragon (1418)

Imagen del santiontanon

19-06-2021, 15:28

Lol, indeed the new obstacles are hard haha, I think I only managed to jump 2 of the obstacles after you cross the 1000 points!

Por Pbk71

Expert (101)

Imagen del Pbk71

22-06-2021, 22:33

I've been working on a bit more balanced level 1 and 2 (level 3 works but is just for testing).

Try it here...

Página 5/5
1 | 2 | 3 | 4 |