Posts: 1,057
Threads: 156
Joined: Aug 2003
can this be stated in a shorter form? the array valules are 0,1,2,3
1 and 3 are walls, 0 and 3 are passable. do you need more info?
Code:
IF press$ = CHR$(0) + CHR$(72) AND map(spritex + 1, spritey - 1) <> 1 AND map(spritex + 1, spritey - 1) <> 2 AND map(spritex + 1, spritey - 1) <> 3 AND map(spritex + 1, spritey) <> 0 AND map(spritex + 1, spritey) <> 3 THEN
Posts: 3,288
Threads: 167
Joined: Nov 2001
Dunno but it could be made more readable. ;*)
If Bleh then
if blah then
if bloh then
end if
end if
end if
Posts: 90
Threads: 8
Joined: Aug 2003
I may supouse that map is an array of integers so..
Code:
IF press$ = CHR$(0) + CHR$(72) AND (map(spritex + 1, spritey - 1) < 0 OR map(spritex + 1, spritey - 1) > 3) THEN
Should work.
Posts: 3,616
Threads: 287
Joined: Jan 2003
If what you're doing is making sure that you aren't to run over a solid wall in an RPG, what I usually do is simply, when loading the map, wherever there's a solid tile, just overwrite it with one special value. Say, 150.
So...
Code:
'Load map...
'..
'..
IF tile=UNWALKABLE1 THEN map(x,y)=150
IF tile=UNWALKABLE2 THEN map(x,y)=150
'etc. etc., for all your unwalkables.
Then, when you press the "d" key to move to the right...
Code:
IF KeyP$="d" AND map(x+1,y)<>150 THEN...
'code to move right
END IF
Hope that helps. Although what xhantt said too also works.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 1,956
Threads: 65
Joined: Jun 2003
Quote:....
Code:
IF press$ = CHR$(0) + CHR$(72) AND map(spritex + 1, spritey - 1) <> 1 AND map(spritex + 1, spritey - 1) <> 2 AND map(spritex + 1, spritey - 1) <> 3 AND map(spritex + 1, spritey) <> 0 AND map(spritex + 1, spritey) <> 3 THEN
The giant IF statement could be made more understandable if you set up 2 variables before the IF, like:
Code:
XMAP =map(spritex + 1, spritey)
XMAPM1=map(spritex + 1, spritey - 1)
IF press$ = CHR$(0)+CHR$(72) AND XMAPM1<>1 AND XMAPM1<>2 AND XMAPM1<>3 AND XMAP<>0 AND XMAP<>3 THEN
*****