New Programmer needs help w/ moving graphics by player

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
jetq111
Newbie
Posts: 6
Joined: Sun Oct 15, 2006 7:03 am

New Programmer needs help w/ moving graphics by player

Post by jetq111 »

hey
I need help. I need to know how you can make a DATA statement move around the screen when the player presses a button (IE wasd)

Also I need help stopping the players character from crashing into walls, (and making the walls dissaper)

If you can answer this it will be a great help

thnxs
jetq111
4815162342
bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm »

Code: Select all

' Nixon posted this over a year ago.
DIM map(100, 100)
FOR y = 1 TO 5
FOR x = 1 TO 5
READ map(x, y)
LOCATE y, x
IF map(x, y) = 1 THEN PRINT CHR$(219)
NEXT: NEXT
px = 2
py = 2

top:
LOCATE py, px: PRINT CHR$(2)
DO: P$ = INKEY$: LOOP UNTIL P$ <> ""
LOCATE py, px: PRINT " "
IF P$ = "8" AND map(px, py - 1) = 0 THEN py = py - 1
IF P$ = "5" AND map(px, py + 1) = 0 THEN py = py + 1
IF P$ = "4" AND map(px - 1, py) = 0 THEN px = px - 1
IF P$ = "6" AND map(px + 1, py) = 0 THEN px = px + 1
GOTO top

DATA 1,1,1,1,1
DATA 1,0,0,0,1
DATA 1,0,1,0,1
DATA 1,0,0,0,1
DATA 1,1,1,1,1 
Ok. There is at least 50 tutorials for things you asked.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Darkdread wrote great tutorials on this very subject. They are basically the staple of this type of thing. Also, tilex is a pretty OK tutorial for beginners. Both can be found in the tutorials section.
Image
Post Reply