Page 2 of 2

Posted: Sat May 02, 2009 5:13 am
by izidor
It doesn't work

Posted: Sat May 02, 2009 5:29 am
by izidor
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,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,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
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)

Here dammit!

Posted: Sat May 02, 2009 11:59 am
by burger2227

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)
Why are you using LOCATE in graphics?

Posted: Sat May 02, 2009 12:14 pm
by izidor
Why not?
Code works but it doesn't let me go on some positions that are floor.

Posted: Sat May 02, 2009 12:56 pm
by burger2227
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:

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 
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.

Posted: Sat May 02, 2009 1:07 pm
by izidor
Now it is perfect!
Thanks for all help. But can i define x and y of window screen because now it is little down.
And why do I have to press same key two times in a moment? (if you know)

Posted: Sat May 02, 2009 2:09 pm
by burger2227
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!

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,6,6,6,6,6,6
DATA 0,0,0,0,0,0,0,0,0,0

'door
DATA 1,1,1,1,1,1,1,1,1,1
DATA 1,9,9,9,9,9,9,9,9,1
DATA 1,9,9,1,1,1,1,9,9,1
DATA 1,9,1,9,9,9,9,1,9,1
DATA 1,6,6,9,1,1,9,1,9,1
DATA 1,6,6,9,1,1,9,1,9,1
DATA 1,9,1,9,9,9,9,1,9,1
DATA 1,9,9,1,1,1,1,9,9,1
DATA 1,9,9,9,9,9,9,9,9,1
DATA 1,1,1,1,1,1,1,1,1,1

'player
DATA 6,6,0,0,0,0,0,0,6,6
DATA 0,0,0,7,0,0,7,0,0,0
DATA 6,6,0,0,0,0,0,0,6,6
DATA 0,0,0,12,12,12,12,0,0,0
DATA 6,6,2,2,2,2,2,2,6,6
DATA 1,1,2,2,2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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)
My keyboard works fine with the changes. Nice work!

Posted: Sat May 02, 2009 3:10 pm
by burger2227
Are you aware that you can label DATA blocks? This allows you to use more than one MAP in the game.

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

You can use RESTORE map1 to use that map data later. You don't need to read data sequencially that way.

Code: Select all

RESTORE map1
FOR y = 0 TO 18 
FOR x = 0 TO 19 
READ map(x, y) 
NEXT: NEXT 
Never place comments after a data line without a colon at the end of data line!

Posted: Sun May 03, 2009 5:52 am
by izidor
Thanks if there weren't for you I would never finished this game engine.
Thanks for everything ! :D

Posted: Sun May 03, 2009 7:05 am
by izidor
Here i go again.
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
But it didn't work.
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,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,6,6
DATA 0,0,0,0,0,0,0,0,0,0

'door
DATA 1,1,1,1,1,1,1,1,1,1
DATA 1,9,9,9,9,9,9,9,9,1
DATA 1,9,9,1,1,1,1,9,9,1
DATA 1,9,1,9,9,9,9,1,9,1
DATA 1,6,6,9,1,1,9,1,9,1
DATA 1,6,6,9,1,1,9,1,9,1
DATA 1,9,1,9,9,9,9,1,9,1
DATA 1,9,9,1,1,1,1,9,9,1
DATA 1,9,9,9,9,9,9,9,9,1
DATA 1,1,1,1,1,1,1,1,1,1

'window
DATA 1,1,1,1,0,0,1,1,1,1
DATA 1,1,1,1,0,0,1,1,1,1
DATA 1,1,1,1,0,0,1,1,1,1
DATA 1,1,1,14,0,0,14,1,1,1
DATA 1,1,14,14,0,0,14,14,1,1
D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,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,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)
ps
Labeling DATA is very useful. Thanks.

Posted: Sun May 03, 2009 7:29 am
by Anonymous
Just write out what needs to happen and write the code to make it happen

* Player moves up
* check map(player x, player y) for diamond
* if it is a diamond
- change map(player x, player y) to floor
- increase player score by 1
* wait for user input

Posted: Sun May 03, 2009 8:17 am
by izidor
Like this?

Code: Select all

k$ = INKEY$
IF k$ = "a" and map(x,y) = 5 then
PUT floor ...
score = score + 1
end if



Posted: Sun May 03, 2009 11:46 am
by burger2227
You forgot to put a 5 in the map! That PUTs your diamond for you. Do all the scoring in the loop!

Code: Select all

IF map(x, y) = 5 THEN  score = score + 10: map(x, y) = 2
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.

Posted: Sun May 03, 2009 12:45 pm
by izidor
Yes but diamond acts like wall you can't go "on" him.

Posted: Sun May 03, 2009 1:16 pm
by burger2227
Sometimes if you add something, you need to change other things.

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 
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!

Posted: Sun May 03, 2009 3:24 pm
by izidor
All works fine! Game with first level will be done tomorrow!
Tomorrow check http://izzysqb.weebly.com in downloads.

Posted: Tue May 05, 2009 2:56 pm
by izidor
How to make it full screen?

Posted: Tue May 05, 2009 3:10 pm
by burger2227
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