Another little game of my

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
izidor
Veteran
Posts: 110
Joined: Wed Apr 22, 2009 3:13 am
Contact:

Another little game of my

Post by izidor »

Hi i am back and i am creating a game (again).
I need some ideas, what to do in game, something to collect?
Here is the code:

Code: Select all

SCREEN 13
DIM wall(10, 10), floor(10, 10), grass(10, 10), grassb(10, 10), flowers(10, 10), water(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), grass

FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), grassb

FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), flowers

FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(10, 10), water

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), grass
IF map(x, y) = 4 THEN PUT (x * 10, y * 10), grassb
IF map(x, y) = 5 THEN PUT (x * 10, y * 10), flowers
IF map(x, y) = 0 THEN PUT (x * 10, y * 10), water

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

'grass
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10

'grassb
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2

'flowers
DATA 2,4,4,2,2,2,2,2,2,2
DATA 2,4,4,2,2,2,2,2,2,2
DATA 2,2,10,2,2,2,2,2,2,2
DATA 2,2,10,2,2,2,2,2,2,2
DATA 2,10,10,10,2,2,2,2,2,2
DATA 2,2,2,2,2,14,14,2,2,2
DATA 2,2,2,2,2,14,14,2,2,2
DATA 2,2,2,2,2,10,2,2,2,2
DATA 2,2,2,2,2,10,2,2,2,2
DATA 2,2,2,2,10,10,10,2,2,2

'water
DATA 1,1,1,1,1,1,1,1,1,1
DATA 1,1,1,1,1,1,7,1,1,1
DATA 1,1,7,1,1,1,1,1,1,1
DATA 1,1,1,1,1,1,1,1,7,1
DATA 1,1,1,1,1,1,1,1,1,1
DATA 1,1,1,1,1,1,1,1,1,1
DATA 1,1,1,1,1,7,1,1,1,1
DATA 1,1,1,1,1,1,1,1,1,1
DATA 1,7,1,1,1,1,1,1,1,1
DATA 1,1,1,7,1,1,1,1,7,1


'player
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,14,14,14,14,10,10,10
DATA 10,10,0,4,0,0,4,0,10,10
DATA 10,10,0,4,3,3,4,0,10,10
DATA 10,10,10,4,3,3,4,10,10,10
DATA 10,10,10,4,3,3,4,10,10,10
DATA 10,10,0,4,3,3,4,0,10,10
DATA 10,10,0,4,4,4,4,0,10,10
DATA 10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10


map1:
DATA 1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1
DATA 1,4,4,4,4,4,4,4,4,4,4,0,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,0,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,0,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,4,4,0,0
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,2,1,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,1
DATA 1,4,2,3,3,3,1,4,4,4,4,4,4,5,5,5,5,5,5,1
DATA 1,4,2,3,5,3,1,4,4,4,4,4,4,5,0,0,0,0,5,1
DATA 1,4,2,3,5,3,1,4,4,4,4,4,4,5,0,0,0,0,5,1
DATA 1,4,2,3,3,3,1,4,4,4,4,4,4,5,5,5,5,5,5,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
LOCATE 1, 27
PRINT "Izzy's mower"

x = 1
y = 17
PUT (x * 10, y * 10), grass
PUT (x * 10, y * 10), player ' start player position

DO
k$ = INKEY$
LOCATE 3, 27
PRINT "Score:"
LOCATE 3, 33
PRINT score
px = x: py = y
if map(x,y) = 5 then
cls
print "Oh no! My flowers, you ruined them!"
sleep 1
SHELL "Mower.exe"
end
end if
if map(x,y) = 2 then
cls
print "Your mower is broken!"
sleep 1
SHELL "Mower.exe"
end
end if

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
IF px <> x OR py <> y THEN
PUT (x * 10, y * 10), player, PSET
PUT (px * 10, py * 10), grass, PSET
END IF

LOOP UNTIL k$ = CHR$(27)

User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

Post by bongomeno »

you should make a series of levels. each like a puzzle/maze. also have golfers walking around or in golf carts.

im liking the graphics btw
angros47
Veteran
Posts: 79
Joined: Mon Sep 08, 2008 12:52 pm
Contact:

Post by angros47 »

What "Mower.exe" is supposed to be?

If you compiled the game to "mower.exe", and used the line:

Code: Select all

SHELL "Mower.exe" 
to restart it, you made a mistake, because:

1) this feature will work only when the game is compiled (or else you'll get a "file not found/bad command or filename")
2) If you compile the game, then you modify the source and run it, the first time you'll run the new (modified) game, the second time the old (unmodified) one.... it will be very easy to have bugs
3) every time the game restart, a new copy of it will be loaded, in a recursive way, filling RAM
4) you can restart your game with a simple RUN (with no arguments). The RUN command will reset the program, and restart it immediatly.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

The GRASSB is nothing more than a 10 X 10 full Box. See LINE statement.

To repeat a procedure, use a loop. Not SHELL! The more files opened and running, the more the memory and resource drain.

QB64 may allow that, but you really don't want to stretch the limits for others who can still run QB.
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
Post Reply