Qbasicnews.com

Full Version: how to switch maps
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
what is the best way to switch maps?
if map(guyx,guyy)=4 then goto map2



map2:

basically everything that was in map1 but with the commands switched to map2?

or what other way is the best like how do you chain?
somthing tells me this is the wrong way and i cant find anything on the subject
This is just a guess but i think you set the area you want it to swithc maps on, and you take note of the x, change the map, change the y co-ordinates to the other end of the screen and display it using the old x and the new y.
is it wrong to use goto?
Quote:is it wrong to use goto?

GOTO is a bad command unless you realy need to.
Programm in some kind of loop
ie:
Code:
intro
prepare game
while done = 0
  load level
  game ' may set done to 1
wend
outro
This is just a 30 second suggestion and will need some work, but basicaly thats it.
i dont really get that. how can i amek it switch maps at a certain spot? should i use the chain command if so what is the chain command how would i use it?
Make two subs.
One for loading a level into memory and one to reset all local level data.
You need to have just one single game loop that can handle different levels and that just calls to these two subs when needed.
If thats not clear, wait for someone with a richer english language Wink
(I could explain if you understand german Wink )
Heyo! I can speak english! =P

1.
GOTO is not a bad command it's that it is easily misused. If used correctly it is quite handy.

2.
Depends on how the maps are stored. If they are stored in bitmap like datastatments (or files) IE:
1,1,1,1,1
0,0,0,1,1
1,1,0,1,1
1,1,0,0,0
1,1,1,1,1

then you can use 1 sub actually (to load it that is)


Psuedo-code
(EDIT: you can also clear and load the other map vars too)
Code:
SUB loadmap (mapnum)
OPEN "map" + mapnum + ".dat"
load the map into an array [map(x,y)] <--- make sure shared
'nuff said.
you can then change x,y pos of the char then use another sub to put the map onto the screen


^-^[/code]