Kirjautuminen

Haku

Tehtävät

Keskustelu: Koodit: QB: Pallon väistely Peli

comi [19.11.2003 19:25:44]

#

Tylsä ja yksinkertainen pallonväistely peli.
Mutta yksinkertaisesti ja nopeasti vain reilussa
tunnissa ohjelmoitu : ) !!!
Sinun on luotava vain ohjelman toimimisen takia
tiedosto score.bas jossa lukee yhdellä rivillä: 0

DIM ball1(1000), ball2(1000), man(1000), ball3(1000), ball4(1000), ball5(1000), ball6(1000)
DIM x(50), y(50), n(50), way(50) AS INTEGER
CLS
delay2 = 10000 ' Suurenna tätä jos peli toimii liian nopeasti tai pienennä jos hitaasti
SCREEN 13
FOR p = 1 TO 6
k = p * 10
CIRCLE (k + 5, 5), 4, p
PAINT (k + 5, 5), p
LINE (k + 3, 4)-(k + 4, 3), 15
NEXT
GET (10, 1)-(20, 11), ball1
GET (20, 1)-(30, 11), ball2
GET (30, 1)-(40, 11), ball3
GET (40, 1)-(50, 11), ball4
GET (50, 1)-(60, 11), ball5
GET (60, 1)-(70, 11), ball6
CIRCLE (50, 50), 1, 14
LINE (50, 51)-(50, 55), 14: LINE (50, 55)-(47, 59), 14: LINE (50, 55)-(53, 59), 14
LINE (46, 53)-(54, 53), 14
GET (46, 49)-(55, 60), man
mainmenu:
OPEN "score.bas" FOR INPUT AS #1
INPUT #1, highscore
CLOSE #1
CLS
FOR l = 1 TO 50
RANDOMIZE TIMER
x(l) = INT(RND * 300) + 9
y(l) = INT(RND * 188) + 1
n(l) = INT(RND * 6) + 1
difficulty = 0
NEXT
DO
c = 0
press$ = INKEY$
FOR l = 1 TO 50
LINE (x(l), y(l))-(x(l) + 10, y(l) + 10), 0, BF
y(l) = y(l) + 1
IF y(l) > 188 THEN y(l) = y(l) - 188
IF n(l) = 1 THEN PUT (x(l), y(l)), ball1
IF n(l) = 2 THEN PUT (x(l), y(l)), ball2
IF n(l) = 3 THEN PUT (x(l), y(l)), ball3
IF n(l) = 4 THEN PUT (x(l), y(l)), ball4
IF n(l) = 5 THEN PUT (x(l), y(l)), ball5
IF n(l) = 6 THEN PUT (x(l), y(l)), ball6
NEXT
LOCATE 2, 5
COLOR 14
PRINT "  COMI'S BALL MASTER"
score = 0
LOCATE 5, 2
PRINT "(A) New Game"
PRINT ""
PRINT " (C) Quit Game"
LOCATE 15, 15
PRINT " High Score: "; highscore
IF press$ = "A" THEN c = 1
IF press$ = "a" THEN c = 1
IF press$ = "C" THEN SYSTEM
IF press$ = "c" THEN SYSTEM
IF press$ = CHR$(27) THEN SYSTEM
LOOP UNTIL c <> 0
IF c = 1 THEN GOTO newgame
GOTO mainmenu

newgame:
CLS
col = 1
DO
c = 0
press$ = INKEY$
COLOR col
LOCATE 1, 1
PRINT " Choose Difficulty:"
LOCATE 3, 1
PRINT " (A) Easy"
LOCATE 5, 1
PRINT " (B) Medium"
LOCATE 7, 1
PRINT " (C) Hard"
col = col + 1
IF col > 255 THEN col = col - 255
IF press$ = "A" THEN c = 1
IF press$ = "B" THEN c = 2
IF press$ = "C" THEN c = 3
IF press$ = "a" THEN c = 1
IF press$ = "b" THEN c = 2
IF press$ = "c" THEN c = 3
IF press$ = CHR$(27) THEN c = 4
LOOP UNTIL c <> 0
IF c = 1 THEN difficulty = 1
IF c = 2 THEN difficulty = 2
IF c = 3 THEN difficulty = 3
IF c = 4 THEN GOTO mainmenu
IF difficulty <> 0 THEN GOTO gamex
GOTO newgame

gamex:
IF difficulty = 1 THEN lives = 5
IF difficulty = 1 THEN balls = 2
IF difficulty = 1 THEN ballcome = 300
IF difficulty = 2 THEN lives = 3
IF difficulty = 2 THEN balls = 4
IF difficulty = 2 THEN ballcome = 300
IF difficulty = 3 THEN lives = 1
IF difficulty = 3 THEN balls = 6
IF difficulty = 3 THEN ballcome = 300
CLS
FOR l = 1 TO 50
RANDOMIZE TIMER
x(l) = INT(RND * 300) + 10
y(l) = INT(RND * 170) + 15
way(l) = INT(RND * 4) + 1
n(l) = INT(RND * 6) + 1
NEXT
xp = 160
yp = 100
oldx = 160
oldy = 100
mine = 0
DO
cev = balls * 180
delay = delay2 - cev
press$ = INKEY$
LINE (2, 10)-(318, 199), 9, B: LINE (3, 11)-(317, 198), 1, B: LINE (4, 12)-(316, 197), 9, B
COLOR 14
LOCATE 1, 1
PRINT "Score: "; score
LOCATE 1, 20
PRINT "Lives: "; lives
LINE (oldx, oldy)-(oldx + 10, oldy + 10), 0, BF
PUT (xp, yp), man
oldx = xp: oldy = yp
FOR l = 1 TO balls
LINE (x(l), y(l))-(x(l) + 10, y(l) + 10), 0, BF
IF way(l) = 1 THEN x(l) = x(l) + 1
IF way(l) = 1 THEN y(l) = y(l) - 1
IF way(l) = 2 THEN y(l) = y(l) + 1
IF way(l) = 2 THEN x(l) = x(l) + 1
IF way(l) = 3 THEN x(l) = x(l) - 1
IF way(l) = 3 THEN y(l) = y(l) + 1
IF way(l) = 4 THEN y(l) = y(l) - 1
IF way(l) = 4 THEN x(l) = x(l) - 1
IF x(l) < 4 AND way(l) = 3 THEN way(l) = 2
IF x(l) < 4 AND way(l) = 4 THEN way(l) = 1
IF x(l) > 306 AND way(l) = 2 THEN way(l) = 3
IF x(l) > 306 AND way(l) = 1 THEN way(l) = 4
IF y(l) < 14 AND way(l) = 1 THEN way(l) = 2
IF y(l) < 14 AND way(l) = 4 THEN way(l) = 3
IF y(l) > 186 AND way(l) = 2 THEN way(l) = 1
IF y(l) > 186 AND way(l) = 3 THEN way(l) = 4
IF n(l) = 1 THEN PUT (x(l), y(l)), ball1
IF n(l) = 2 THEN PUT (x(l), y(l)), ball2
IF n(l) = 3 THEN PUT (x(l), y(l)), ball3
IF n(l) = 4 THEN PUT (x(l), y(l)), ball4
IF n(l) = 5 THEN PUT (x(l), y(l)), ball5
IF n(l) = 6 THEN PUT (x(l), y(l)), ball6
FOR p = x(l) TO x(l) + 9
FOR t = y(l) TO y(l) + 9
IF POINT(p, t) = 14 THEN lives = lives - 1
IF POINT(p, t) = 14 THEN xp = 160
IF POINT(p, t) = 14 THEN yp = 100
IF POINT(p, t) = 14 THEN SLEEP 1
NEXT: NEXT
NEXT
score = score + balls
p = p + 1
IF p > ballcome THEN balls = balls + 1
IF p > ballcome THEN p = 1
IF balls > 50 THEN balls = 50
IF press$ = CHR$(29) AND mine = 0 THEN CIRCLE (xp + 5, yp + 13), 1, 15
IF press$ = CHR$(29) AND mine = 0 THEN minex = xp + 5
IF press$ = CHR$(29) AND mine = 0 THEN miney = yp + 13
IF press$ = CHR$(29) THEN mine = 1
IF press$ = CHR$(0) + CHR$(80) THEN yp = yp + 6
IF press$ = CHR$(0) + CHR$(72) THEN yp = yp - 6
IF press$ = CHR$(0) + CHR$(77) THEN xp = xp + 10
IF press$ = CHR$(0) + CHR$(75) THEN xp = xp - 10
IF xp < 5 THEN xp = xp + 10
IF xp > 305 THEN xp = xp - 10
IF yp < 13 THEN yp = yp + 6
IF yp > 186 THEN yp = yp - 6
FOR c = 1 TO delay
NEXT
IF press$ = CHR$(27) THEN EXIT DO
LOOP UNTIL lives < 0
DO
FOR q = 1 TO 255
LOCATE 13, 16
COLOR q
PRINT "GAME OVER"
NEXT
LOOP WHILE INKEY$ = ""
CLS
IF score > highscore THEN highscore = score
OPEN "score.bas" FOR OUTPUT AS #2
PRINT #2, highscore
CLOSE #2
GOTO mainmenu

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta