Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
movment logic
#1
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
Reply
#2
Dunno but it could be made more readable. ;*)


If Bleh then
if blah then
if bloh then
end if
end if
end if
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#3
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.
Reply
#4
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.
Reply
#5
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
*****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)