Re: A85: help me please


[Prev][Next][Index][Thread]

Re: A85: help me please




> 1)Create say a random number 1-10  

Use Jimmy Mardell's random number routine.  It can be found in the
source code to ZTetris.  Just search for the word Random in the source
code. (I think it uses the label PRandom)

> 2) save and load games 

You have to have somewhere in the game's string to load the game
to/from.  You will need to decide for yorself what all needs to be
saved.  Let's say you want to save the Level number and the number of
lives you have.  Then you would need a place in the string such as:

SavedLives:
  .db 0
SavedLevel:
  .db 0

Or you could create a new string for the saved game with your own
saved game file format, but this is a bit more difficult.  I guess
this would be useful if you wanted to be able to have multiple saved
games.

> 3) create levels for games.

Each level usually consists of a bunch of "tiles".  Each of these is
usually an 8X8 sprite.  This is the best and easiest size to use (it
is simple to multiply and divide by 8 using the z80's shift
instructions).  You simply have an array of bytes telling what sprite
to use for each tile of the screen.  For example, since the screen of
the 85 is 128X64 pixels, this is the same as 16X8 tiles if each tile
is an 8X8 sprite.  So if you used the whole screen (without scrolling)
and each tile was represented by 1 byte, it would take 128 bytes (16
tiles wide X 8 tiles high) to store each level.  You could store the
level as such:

Level0:
 .db 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1	;1 row of tiles
 .db 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
 .db 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
 .db 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
 .db 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
 .db 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
 .db 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
 .db 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0

Sprite0:		;8X8 sprite
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000
 .db %00000000

Sprite1:
 .db %11111111
 .db %11111111
 .db %11111111
 .db %11111111
 .db %11111111
 .db %11111111
 .db %11111111
 .db %11111111

You would now have a routine to draw the level.  It would look at the
number of the tile at Level0 and decide which sprite is the one to
draw and at what x,y coordinate to draw the sprite.

-mike pearce
mgp4007@omega.uta.edu


References: