HomeRobber
This code works perfectly but it doesn't delete its trail
Code: Select all
screen 13
DIM wall(10, 10), floor(10, 10), door(10, 10), player(10, 10)
DIM map(20, 19)
for y = 1 to 10
for x = 1 to 10
read clr
pset (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10),wall
for y = 1 to 10
for x = 1 to 10
read clr
pset (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10),floor
for y = 1 to 10
for x = 1 to 10
read clr
pset (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10),door
for y = 1 to 10
for x = 1 to 10
read clr
pset (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10),player
CLS
for y = 1 to 19
for x = 1 to 20
read map(x, y)
NEXT:NEXT
FOR y = 1 TO 19
FOR x = 1 TO 20
IF map(x, y) = 1 THEN PUT (x * 10 - 10, y * 10 - 10), wall
IF map(x, y) = 2 THEN PUT (x * 10 - 10, y * 10 - 10), floor
IF map(x, y) = 3 THEN PUT (x * 10 - 10, y * 10 - 10), door
IF map(x, y) = 4 THEN PUT (x * 10 - 10, y * 10 - 10), player
NEXT
NEXT
'wall
DATA 0,8,8,8,8,8,8,8,8,0
DATA 8,7,7,8,7,7,7,7,7,8
DATA 8,8,8,8,8,8,8,8,8,8
DATA 8,7,7,7,7,7,8,7,7,8
DATA 8,8,8,8,8,8,8,8,8,8
DATA 8,7,7,8,7,7,7,7,7,8
DATA 8,8,8,8,8,8,8,8,8,8
DATA 8,7,7,8,7,7,8,7,7,8
DATA 8,7,7,8,7,7,8,7,7,8
DATA 0,8,8,8,8,8,8,8,8,0
'floor
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,6,6,6,6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2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
x=2
y=18
PUT (x * 10, y * 10), player 'FORGET THE -10 idea everywhere!
'delete the floor PUT
do
k$=INKEY$
if k$ = chr$(100) then
x = x + 1
locate x,y
PUT (x * 10 - 10, y * 10 - 10), player
PUT (x * 10 - 10, y * 10 - 10), floor
end if
if k$ = chr$(97) then
x = x - 1
locate x,y
PUT (x * 10 - 10, y * 10 - 10), player
PUT (x * 10 - 10, y * 10 - 10), floor
end if
if k$ = chr$(119) then
y = y - 1
locate x,y
PUT (x * 10 - 10, y * 10 - 10), player
PUT (x * 10 - 10, y * 10 - 10), floor
end if
if k$ = chr$(115) then
y = y + 1
locate x,y
PUT (x * 10 - 10, y * 10 - 10), player
PUT (x * 10 - 10, y * 10 - 10), floor
end if
loop until k$ = chr$(27)
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Here dammit!
Code: Select all
do
k$=INKEY$
px = x: py = y
if k$ = chr$(100) AND map(x + 1, y) = 2 then x = x + 1
if k$ = chr$(97) AND map(x - 1, y) = 2 then x = x - 1
if k$ = chr$(119) AND map(x, y - 1) = 2 then y = y - 1
if k$ = chr$(115) AND map(x, y + 1) = 2 then y = y + 1
IF px <> x OR py <> y THEN
PUT (x * 10, y * 10), player, PSET
PUT (px * 10, py * 10), floor, PSET
END IF
loop until k$ = chr$(27)
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Get rid of the - 10 's in your map PUTs. All you are doing is moving the map left one placement. Code below will have a 10 pixel black border:
This should now align the map to the graphics. If you want to use x = 0 then use it in your FOR loops above. Subtract one from the maximums! You will have to use 0's in your map array READ also.
Code: Select all
FOR y = 1 TO 19
FOR x = 1 TO 20
IF map(x, y) = 1 THEN PUT (x * 10, y * 10), wall
IF map(x, y) = 2 THEN PUT (x * 10, y * 10), floor
IF map(x, y) = 3 THEN PUT (x * 10, y * 10), door
IF map(x, y) = 4 THEN PUT (x * 10, y * 10), player
NEXT
NEXT
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Yes, you can change the y values from 0 to 18. You will have to make the player y start position 17 or an error will happen.
ALSO, WATCH OUT for the DOORS! You did not map beyond them so the map array holds no values.
IF map(x,y) = 3 THEN GOTO next room..........
NOW you can place objects without subtracting 10 all of the time!
My keyboard works fine with the changes. Nice work!
ALSO, WATCH OUT for the DOORS! You did not map beyond them so the map array holds no values.
IF map(x,y) = 3 THEN GOTO next room..........
NOW you can place objects without subtracting 10 all of the time!
Code: Select all
SCREEN 13
DIM wall(10, 10), floor(10, 10), door(10, 10), player(10, 10)
DIM map(20, 19)
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), wall
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), floor
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), door
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), player
CLS
FOR y = 0 TO 18
FOR x = 0 TO 19
READ map(x, y)
NEXT: NEXT
FOR y = 0 TO 18
FOR x = 0 TO 19
IF map(x, y) = 1 THEN PUT (x * 10, y * 10), wall
IF map(x, y) = 2 THEN PUT (x * 10, y * 10), floor
IF map(x, y) = 3 THEN PUT (x * 10, y * 10), door
NEXT: NEXT
'wall
DATA 0,8,8,8,8,8,8,8,8,0
DATA 8,7,7,8,7,7,7,7,7,8
DATA 8,8,8,8,8,8,8,8,8,8
DATA 8,7,7,7,7,7,8,7,7,8
DATA 8,8,8,8,8,8,8,8,8,8
DATA 8,7,7,8,7,7,7,7,7,8
DATA 8,8,8,8,8,8,8,8,8,8
DATA 8,7,7,8,7,7,8,7,7,8
DATA 8,7,7,8,7,7,8,7,7,8
DATA 0,8,8,8,8,8,8,8,8,0
'floor
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0
DATA 6,6,6,6,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,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
x = 2
y = 17
PUT (x * 10, y * 10), player ' start player position
DO
k$ = INKEY$
px = x: py = y
IF k$ = CHR$(100) AND map(x + 1, y) = 2 THEN x = x + 1
IF k$ = CHR$(97) AND map(x - 1, y) = 2 THEN x = x - 1
IF k$ = CHR$(119) AND map(x, y - 1) = 2 THEN y = y - 1
IF k$ = CHR$(115) AND map(x, y + 1) = 2 THEN y = y + 1
IF px <> x OR py <> y THEN
PUT (x * 10, y * 10), player, PSET
PUT (px * 10, py * 10), floor, PSET
END IF
LOOP UNTIL k$ = CHR$(27)
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Are you aware that you can label DATA blocks? This allows you to use more than one MAP in the game.
You can use RESTORE map1 to use that map data later. You don't need to read data sequencially that way.
Never place comments after a data line without a colon at the end of data line!
Code: Select all
map1: 'data field label
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
map2: 'second map data
Code: Select all
RESTORE map1
FOR y = 0 TO 18
FOR x = 0 TO 19
READ map(x, y)
NEXT: NEXT
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Here i go again.
I have out a diamond in the game, but how to make my score go + 1.
I was trying with
But it didn't work.
Do you have any ideas or somebody else?
ps
Labeling DATA is very useful. Thanks.
I have out a diamond in the game, but how to make my score go + 1.
I was trying with
Code: Select all
IF player(x, y) = diamond(x, y) then
score = score + 1
END IF
Do you have any ideas or somebody else?
Code: Select all
SCREEN 13
DIM wall(10, 10), floor(10, 10), door(10, 10), window(10, 10),diamond(10, 10), player(10, 10)
DIM map(20, 19)
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), wall
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), floor
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), door
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), window
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), diamond
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), player
CLS
RESTORE map1
FOR y = 0 TO 18
FOR x = 0 TO 19
READ map(x, y)
NEXT: NEXT
FOR y = 0 TO 18
FOR x = 0 TO 19
IF map(x, y) = 1 THEN PUT (x * 10, y * 10), wall
IF map(x, y) = 2 THEN PUT (x * 10, y * 10), floor
IF map(x, y) = 3 THEN PUT (x * 10, y * 10), door
IF map(x, y) = 4 THEN PUT (x * 10, y * 10), window
IF map(x, y) = 5 THEN PUT (x * 10, y * 10), diamond
NEXT: NEXT
'wall
DATA 0,8,8,8,8,8,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2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
DATA 1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
locate 1,27
print "House Robber"
locate 3,27
print "Score:"
score = 0
locate 3, 33
print score
x= 2
y= 16
PUT (x * 10, y * 10), floor
PUT (x * 10, y * 10), diamond
x = 2
y = 17
PUT (x * 10, y * 10), floor
PUT (x * 10, y * 10), player ' start player position
DO
k$ = INKEY$
px = x: py = y
IF k$ = CHR$(100) AND map(x + 1, y) = 2 THEN x = x + 1
IF k$ = CHR$(97) AND map(x - 1, y) = 2 THEN x = x - 1
IF k$ = CHR$(119) AND map(x, y - 1) = 2 THEN y = y - 1
IF k$ = CHR$(115) AND map(x, y + 1) = 2 THEN y = y + 1
IF px <> x OR py <> y THEN
PUT (x * 10, y * 10), player, PSET
PUT (px * 10, py * 10), floor, PSET
END IF
LOOP UNTIL k$ = CHR$(27)
Labeling DATA is very useful. Thanks.
Like this?
Code: Select all
k$ = INKEY$
IF k$ = "a" and map(x,y) = 5 then
PUT floor ...
score = score + 1
end if
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
You forgot to put a 5 in the map! That PUTs your diamond for you. Do all the scoring in the loop!
You want the player to move to the diamond position to pick it up. After another move, the floor will follow with the 2 PUTs already used in the keypress moves.
Change the value in the map array to 2 (floor) because the diamond has been picked up. You can do this for ALL other objects you place in the floor areas.
Code: Select all
IF map(x, y) = 5 THEN score = score + 10: map(x, y) = 2
Change the value in the map array to 2 (floor) because the diamond has been picked up. You can do this for ALL other objects you place in the floor areas.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Sometimes if you add something, you need to change other things.
Now you can add other objects using map numbers above 1. Values of 0 or 1 will not move the player.
You might have noticed that I kept your map array so that the map array is larger than the map. So the right and down moves at a door will = 0.
If I did not do this, a move check of the map array would have tried to access an array index that was not there. That causes an error!
Code: Select all
IF k$ = CHR$(100) AND map(x + 1, y) > 1 THEN x = x + 1
IF k$ = CHR$(97) AND map(x - 1, y) > 1 THEN x = x - 1
IF k$ = CHR$(119) AND map(x, y - 1) > 1 THEN y = y - 1
IF k$ = CHR$(115) AND map(x, y + 1) > 1 THEN y = y + 1
You might have noticed that I kept your map array so that the map array is larger than the map. So the right and down moves at a door will = 0.
If I did not do this, a move check of the map array would have tried to access an array index that was not there. That causes an error!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
All works fine! Game with first level will be done tomorrow!
Tomorrow check http://izzysqb.weebly.com in downloads.
Tomorrow check http://izzysqb.weebly.com in downloads.
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
It is fullscreen in QB!
QB64 however uses a smaller screen 13 because it is only 320 X 200 in a window.
I don't think that there is presently a way to make it fullscreen. There definately SHOULD be!
In the meantime, just use QB compiles or BAS files for downloads. There are still many XP and older machines running DOS.
Ted
QB64 however uses a smaller screen 13 because it is only 320 X 200 in a window.
I don't think that there is presently a way to make it fullscreen. There definately SHOULD be!
In the meantime, just use QB compiles or BAS files for downloads. There are still many XP and older machines running DOS.
Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0