Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
game movement
#1
it's off by one or something so it dosnt cover up all the movement. what i dont get is that it works for moving a pixle around but it wont work for this.

Code:
SCREEN 12

FOR y = 1 TO 5
FOR x = 1 TO 7
READ map
IF map = 1 THEN LOCATE y, x: PRINT "#"
IF map = 0 THEN LOCATE y, x: PRINT "."
NEXT
NEXT

yy = 4: xx = 6
oldyy = yy: oldxx = xx
DO
press$ = INKEY$

IF LCASE$(press$) = "a" THEN
    xx = xx - 1
    LOCATE yy, xx + 1: PRINT "."
    
END IF
IF LCASE$(press$) = "d" THEN
    xx = xx + 1
    LOCATE y, x - 1: PRINT "."
    
END IF
IF LCASE$(press$) = "w" THEN
    yy = yy - 1
    LOCATE yy + 1, xx: PRINT "."
    
END IF
IF LCASE$(press$) = "s" THEN
    yy = yy + 1
    LOCATE yy - 1, xx: PRINT "."
    
END IF

LOCATE yy, xx: PRINT "@"
LOOP UNTIL press$ = CHR$(27)

DATA 1,1,1,1,1,1,1
DATA 1,0,0,0,0,0,1
DATA 1,0,0,0,0,0,0
DATA 1,0,0,0,0,0,1
DATA 1,1,1,1,1,1,1
Reply
#2
Code:
IF LCASE$(press$)="d" THEN
xx = xx + 1
LOCATE y, x - 1: PRINT "."
END IF
You should LOCATE yy,xx-1 instead - not y,x.
[edit] Just thought I should explain why...
Since x and y were once used - to load the map. So they aren't holding the postition of the @ - so you're LOCATEing the wrong position completely.
Common typo-error. Smile
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#3
Blarg...It's always those with me. Thanks. if you cant tell I’m working on the rouge game. I haven’t figured out the part when you walk down a hallway and all you see is a few steps ahead of you. I was thinking of making a big bitmap and reading it but having some way of restricting how much is displayed. Suggestions?
Reply
#4
I'm not sure what you mean...Afee steps? Huh?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#5
Ok more to it now: I know I can use a$ = string$(number_of_spaces,character) for text boxes and stats. What else needs fixing? About the movement: in the game I want the player to only see areas that have light or have already been explored, so the lower half of the map you would not see untill you go there.
Reply
#6
Dirgoa, proofread your messages! I didn't understand a word of the last one!

Quote:Ok more to it now: I know I can use a$=string$(#spc,chr) [huh?]. What else needs fixing? About the movement: in the game I want the player to only see areas that have light or have already been explored, so the lower half of the map you would not see untill you go there.

Ok, so for this implementation of explored areas and visible areas, you need an explored areas array as big as the map itself and a visibility formula.

Common visibility formula:
Anything in a certain radius of the observer where no walls block the observer.. simply use bresenham formula in circles.

You have a lot of work to do..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#7
bresenham formula? this sounds bad.
Reply
#8
Bresenham = line formula.

What you want to do is trace paths (line) from all points on the circumference of your "circle" to your player (who would be in the center of the circle), and Bresenham allows you to do that.

Search for it. In this case, it would mater A LOT from what point you start (center of circumference point): you keep everything visible until you hit a wall or until you get to the maximum visibility radius.

Also you'll need a formula to get all the points in your circle's circumference.. (radius is again the maximum visibility radius)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#9
You could also use a rectangle. it is much easier to compute.

Code:
FOR x = xPlayer - xVisibility TO xPlayer + xVisibility
  FOR y = yPlayer - yVisibility TO yPlayer + yVisibility
    MakeVisible(x, y)
  NEXT
NEXT
If you are using text mode or tiles, you need to be careful that you don't try to PRINT or PUT outside the screen or you will get errors.

If you want to be able to return to a room and be able to see what you've aready explored then you should have an explored areas array for each room, as Aga suggessted. If you don't care about that and each room fits on the screen, You can just update the screen each time you move.
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Reply
#10
That rectangle code won't work because you don't take walls into account.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)