Just to quickly introduce myself, I'm a 32 year old multimedia designer and retro graphics geek with fond memories of the Atari 2600. I'm a self-taught, halfway-decent programmer in wimpy languages like Java and Actionscipt, but I sort of skipped over the "Basic" portion of my education. I've been using bB for about a week now, and its definitely the stepping stone I need to work my way into assembly (thanks, Fred!)
The game I'm working on is an adventure that requires screen-to-screen movement, with new rooms to be drawn by accessing segments of a data set, (which I imaginatively named 'gamemap'). In other languages this process is pretty simple to accomplish, but I'm running into a few problems in bB, since it doesn't seem like you can nest arrays.
In my code, I have a sets of fifteen values that describe how to draw a room and objects inside it, including things like the span of lines to draw and arguments that are passed to certain interactive objects of the playfield for use in the gameloop. In my posted binary, my sample room object is a Teleporter activated by the button, that sends you up or down depending on which floor you are on.
For example:
data gamemap 137, 13, 85, 20, 12, 135, 138, 85, 20, 30, 31, 7, 2, 85, 45, //This is room 1 end drawElevator // This is drawing the elevator graphics in my program, and setting the animating portions to off if gamemap[4]=12 then pfvline gamemap[9] 0 11 : pfvline gamemap[10] 0 11 if gamemap[4]=12 then pfpixel gamemap[9] gamemap[11] off : pfpixel gamemap[10] gamemap[11] off if gamemap[4]=12 then pfpixel gamemap[9] gamemap[12] off : pfpixel gamemap[10] gamemap[12] off gameloop (...) updateBackgroundOb function tElevator if x<gamemap[5] || x>gamemap[6] then playerTouching = 0 : yAdj = 0 if y>gamemap[7] || y<gamemap[8] then playerTouching = 0 : yAdj = 0 if x>=gamemap[5] && x<=gamemap[6] && y<=gamemap[7] && y>=gamemap[8] then playerTouching = 12 : yAdj = 2 end if gamemap[4] = 12 then bgobj = tElevator : gosub Elevators (...) goto gameloop
In the above example, the gameloop finds the values it needs for the elevators by pointing to static positions of the array. As you can see in my attached BIN, this all works like a charm for a single room. But for moving from room to room, what I really need is something like the following:
const roomsize = 15 //The length of a segment that describes a single room roomvar=0 data gamemap 137, 13, 85, 20, 12, 135, 138, 85, 20, 30, 31, 7, 2, 85, 45, //This is room 1 137, 13, 85, 20, 12, 90, 94, 85, 20, 20, 21, 7, 2, 85, 45 //This is room 2 end gameloop curroom = roomsize * roomvar //The multiplier that points to the appropriate segment of gamemap (...) if x>rightside then roomvar=roomvar+1 : gosub newRoom updateBackgroundOb function tElevator if x<gamemap[5+curroom] || x>gamemap[6+curroom] then playerTouching = 0 : yAdj = 0 if y>gamemap[7]+curroom || y<gamemap[8+curroom] then playerTouching = 0 : yAdj = 0 if x>=gamemap[5+curroom] && x<=gamemap[6+curroom] && y<=gamemap[7+curroom] && y>=gamemap[8+curroom] then playerTouching = 12 : yAdj = 2 end if gamemap[4+curroom] = 12 then bgobj = tElevator : gosub Elevators (...) goto gameloop newRoom (...) drawElevator if gamemap[4+curroom]=12 then pfvline gamemap[9+curroom] 0 11 : pfvline gamemap[10+curroom] 0 11 if gamemap[4+curroom]=12 then pfpixel gamemap[9+curroom] gamemap[11+curroom] off : pfpixel gamemap[10+curroom] gamemap[11+curroom] off if gamemap[4+curroom]=12 then pfpixel gamemap[9+curroom] gamemap[12+curroom] off : pfpixel gamemap[10+curroom] gamemap[12+curroom] off return
The idea is, when you exited the room you were in, the next room would be drawn by locating the next set of fifteen values, and all the methods and functions would access to that set. Basically I thought this would be a way of simulating multidimensional arrays, but I recieve errors on the expression gameMap[somevalue + curroom]. I know that bB arrays aren't writable, but does anyone know of a good sound way I can move a pointer around in my array?
Thanks in advance for any help you can give me. As a side note, I'm really excited about writing my first Atari game, and if I can get my screen-to-screen movement to function, I plan to contribute to the community by writing a "level editor" in Java or Flash that would let authors quickly define playfield areas and their arguments, then output the proper bB code for insertion into projects.
Cheers,
Jarod
"Mutant Armageddon" tech demo
Instructions:
Joystick left/right - moves character
Joysick down - duck!
Button - Use/activate elevator (when standing on it)
EDT:
The monsters in this demo are dumb as doorknobs right now, moving in a single direction. They will be plenty smart eventually, and if I can implement my screen-to-screen technique, their positions will be updated in new rooms based on where they last left the screen, simulating map "roaming".
Attached Files
Edited by jrok, Wed Sep 17, 2008 1:03 PM.















