Posts: 18
Threads: 7
Joined: Aug 2004
OK...i wanna start an rpg. I've downloaded EVERY tut i can find...alot help. OK...i'm working on a scroller(simple tile-by-tile) in all the tuts i find have a seprate array for each tile and the tiles are hard coded in to the game.I want to load a tile set into an array, so i can change tilesets. OH... whats the best why to do the passibility? do i need to make a layer for it?? I know this is a long post, maybe i'm tring to bite off more than i can chew...but you gotta start somewhere ...I would appreciate help...THANX!
Posts: 719
Threads: 72
Joined: Mar 2003
well, i suggest using 16x16 tiles...
Here is how it should generally go..
<<please note that the map size can be changed>>
Code: DIM Tileset(NumberofTiles, ((16*16)\2)+1) AS INTEGER
DIM Map(15, 15) AS INTEGER
FOR mpx% = 0 to 15
FOR mpy% = 0 to 15
READ tileindex%
Map(mpx%, mpy%) = tileindex%
NEXT mpy%, mpx%
DO
'This code needs to be modified to accept correct keyboard handling
IF keyboard = UP THEN
MapShowY = MapShowY - 1
If MapShowY < 1 THEN MapShowY = 1
END IF
IF keyboard = DOWN THEN
MapShowY = MapShowY + 1
If MapShowY > 15 THEN MapShowY = (15 - NotilesVertically)
END IF
IF keyboard = LEFT THEN
MapShowX = MapShowX - 1
If MapShowX < 1 THEN MapShowX = 1
END IF
IF keyboard = Right THEN
MapShowX = MapShowX + 1
If MapShowX < 1 THEN MapShowX = (15 - NotilesHorizontally)
END IF
FOR Smx% = MapShowX to MapShowX + NoTilesHorizontally
FOR Smy% = MapShowY to MapShowY + NoTilesVertically
PUT ((Smx% - MapShowX) + 1, (Smy% - MapShowY) + 1), Tileset(Map(Smx%, Smy%), 0), PSET
NEXT Smy%, Smx%
Loop until Keyboard = ESC
END
MapStuff:
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
DATA 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00
Posts: 594
Threads: 11
Joined: Oct 2002
You can optimize this code by drawing the map only when MapShowX or MapShowY has been changed....
B 4 EVER
Posts: 719
Threads: 72
Joined: Mar 2003
i was jsut doing that code off the top of my head, so there is bound to b ways of making it faster.
Oz~
Posts: 6,419
Threads: 74
Joined: Mar 2002
check the order of the dimmensions in the array that holds the tiles. It is reversed (QB stores stuff in column order, so it should be DIM Tileset(16*16\2+1, NumberOfTiles) AS INTEGER).
Posts: 116
Threads: 5
Joined: Jul 2004
Quote:OK...i wanna start an rpg. I've downloaded EVERY tut i can find...alot help. OK...i'm working on a scroller(simple tile-by-tile) in all the tuts i find have a seprate array for each tile and the tiles are hard coded in to the game.I want to load a tile set into an array, so i can change tilesets. OH... whats the best why to do the passibility? do i need to make a layer for it?? I know this is a long post, maybe i'm tring to bite off more than i can chew...but you gotta start somewhere ...I would appreciate help...THANX!
If your tiles are standard QB GET/PUT format, then you can use this code...(Assuming your using SCREEN 13 too.)
'
'This gets the length of bytes the tile set contains...
'
Code: '
DEFINT A-Z
FileNum = FREEFILE
OPEN file$ FOR BINARY ACCESS READ AS FileNum
length& = LOF(FileNum) - 7
CLOSE FileNum
'
'This code dimensions an array, if file$ exists, which will hold your tile set, and then BLOADS it into the array...
Code: IF length& THEN
Words = (length& \ 2) - 1
REDIM ARRAY(0 TO Words)
DEF SEG = VARSEG(ARRAY(0))
BLOAD file$, 0
END IF
Now you can use your tiles just like normal
Cya.
|