Kirjautuminen

Haku

Tehtävät

Keskustelu: Koodit: QB: Tennispeli

rndprogy [23.09.2003 18:27:27]

#

Tässä on pelaat tietokonetta vastaan tennistä jossa on mailat/laudat on ylä- ja alareunassa.

'      *****************************************************************
'      *QBasic Tennis Made by "rndprogy" to ohjelmointiputka.net       *
'      *Test free and give comments TO ME!    Credit year 2003.23.09   *
'      *****************************************************************
'

SCREEN 13: RANDOMIZE TIMER
SCREEN 0
LOCATE 5, 1: INPUT "Ja mihin asti pelataan (20=default)", B
SCREEN 13
I = .09
0 Q = 150: W = 0: R = 100: T = 0: E = 158: P = .05: D = 4
A = 150: U = 0: H = 0
S = INT(RND * 300) + 1
DO
'Pelaajan lauta
LINE (Q,180)-(Q+20,183),4,BF:LINE (Q-1,179)-(Q+21,184),0, B
'pallo
LINE (E,R)-(E+3,R+3),9,BF:LINE (E-1,R-1)-(E+4, R + 4), 0, B
'Tietokoneen lauta
LINE (A,20)-(A+20,23),2,BF:LINE (A-1,19)-(A + 21, 24), 0, B
A$ = INKEY$
'ja nyt jossitellaan
'laudan ohjaus
IF A$ = CHR$(0) + "K" THEN W = 1
IF A$ = CHR$(0) + "M" THEN W = 2
'Laudan pysätytys
IF A$ = CHR$(0) + "M" AND U > 1 AND W = 2 THEN U = 0: W = 0
IF A$ = CHR$(0) + "K" AND U > 1 AND W = 1 THEN U = 0: W = 0
IF A$ = CHR$(27) THEN END
IF W = 1 THEN Q = Q - .1 * D: U = U + 1
IF W = 2 THEN Q = Q + .1 * D: U = U + 1
IF Q < 0 THEN Q = Q + 1
IF Q > 299 THEN Q = Q - 1

'Pallon ohjaus pelaajan laudasta
IF E>Q-3 AND E<Q-2 AND R>175 AND R < 176 THEN T = 1: P = 1
IF E>Q-2 AND E<Q-1 AND R>175 AND R < 176 THEN T = 1: P = .9
IF E>Q-1 AND E<Q AND R > 175 AND R < 176 THEN T = 1: P = .8
IF E>Q AND E<Q+1 AND R > 175 AND R < 176 THEN T = 1: P = .7
IF E> Q+1 AND E<Q+2 AND R>175 AND R< 176 THEN T = 1: P = .6
IF E> Q+2 AND E<Q+3 AND R>175 AND R< 176 THEN T = 1: P = .5
IF E>Q+3 AND E<Q+4 AND R>175 AND R < 176 THEN T = 1: P = .4
IF E>Q+4 AND E<Q+5 AND R>175 AND R < 176 THEN T = 1: P = .3
IF E>Q+5 AND E<Q+6 AND R>175 AND R < 176 THEN T = 1: P = .2
IF E>Q+6 AND E<Q+7 AND R>175 AND R < 176 THEN T = 1: P = .1
IF E>Q+7 AND E<Q+8 AND R>175AND R < 176 THEN T = 1: P = .05
IF E>Q+8 AND E<Q+9 AND R> 175 AND R < 176 THEN T = 2: P = 0
IF E>Q+9 AND E<Q+10 AND R>175 AND R<176 THEN T = 2: P = .05
IF E>Q+10 AND E<Q+11 AND R>175 AND R<176 THEN T = 2: P = .1
IF E>Q+11 AND E<Q+12 AND R>175 AND R<176 THEN T = 2: P = .2
IF E>Q+12 AND E<Q+13 AND R>175 AND R<176 THEN T = 2: P = .3
IF E>Q+13 AND E<Q+14 AND R>175 AND R<176 THEN T = 2: P = .4
IF E>Q+14 AND E<Q+15 AND R>175 AND R<176 THEN T = 2: P = .5
IF E>Q+15 AND E<Q+16 AND R>175 AND R<176 THEN T = 2: P = .6
IF E>Q+16 AND E<Q+17 AND R>175 AND R<176 THEN T = 2: P = .7
IF E>Q+17 AND E<Q+18 AND R>175 AND R<176 THEN T = 2: P = .8
IF E>Q+18 AND E<Q+19 AND R>175 AND R<176 THEN T = 2: P = .9
IF E>Q+19 AND E<Q+20 AND R>175 AND R<176 THEN T = 2: P = 1

'Pallon kimpoaminen seinästä
IF G = 1 AND R > 170 AND T = 1 THEN T = 3: H = H + 1
IF G = 1 AND R > 170 AND T = 4 THEN T = 2: H = H + 1
IF G = 1 AND R > 170 AND T = 3 THEN T = 1: H = H + 1
IF G = 1 AND R > 170 AND T = 2 THEN T = 4: H = H + 1

IF T = 1 THEN R = R - I * D: E = E - P
IF E < 0 AND T = 1 THEN T = 2
IF T = 0 THEN R = R - I * D
IF T = 2 THEN R = R - I * D: E = E + P

'Pallon ohjaus vastustajan laudasta
IF E>A-3 AND E<A- 2 AND R < 25 AND R > 24 THEN T = 3: P = 1
IF E>A-2 AND E<A- 1 AND R < 25 AND R > 24 THEN T = 3: P = .9
IF E>A-1 AND E<A AND R < 25 AND R > 24 THEN T = 3: P = .8
IF E>A AND E<A+ 1 AND R < 25 AND R > 24 THEN T = 3: P = .7
IF E>A+1 AND E<A+ 2 AND R < 25 AND R > 24 THEN T = 3: P = .6
IF E>A+2 AND E<A+ 3 AND R < 25 AND R > 24 THEN T = 3: P = .5
IF E>A+3 AND E<A+ 4 AND R < 25 AND R > 24 THEN T = 3: P = .4
IF E>A+4 AND E<A+ 5 AND R < 25 AND R > 24 THEN T = 3: P = .3
IF E>A+5 AND E<A+ 6 AND R < 25 AND R > 24 THEN T = 3: P = .2
IF E>A+6 AND E<A+ 7 AND R < 25 AND R > 24 THEN T = 3: P = .1
IF E>A+7 AND E<A+8 AND R < 25 AND R > 24 THEN T = 3: P = .05
IF E>A+8 AND E<A+ 9 AND R < 25 AND R > 24 THEN T = 4: P = 0
IF E>A+9 AND E<A+10 AND R< 25 AND R > 24 THEN T = 4: P = .05
IF E>A+10 AND E<A+11 AND R<25 AND R > 24 THEN T = 4: P = .1
IF E>A+11 AND E<A+12 AND R<25 AND R > 24 THEN T = 4: P = .2
IF E>A+12 AND E<A+13 AND R<25 AND R > 24 THEN T = 4: P = .3
IF E>A+13 AND E<A+14 AND R< 25 AND R > 24 THEN T = 4: P = .4
IF E>A+14 AND E<A+15 AND R< 25 AND R > 24 THEN T = 4: P = .5
IF E>A+15 AND E<A+16 AND R< 25 AND R > 24 THEN T = 4: P = .6
IF E>A+16 AND E<A+17 AND R< 25 AND R > 24 THEN T = 4: P = .7
IF E>A+17 AND E<A+18 AND R< 25 AND R > 24 THEN T = 4: P = .8
IF E>A+18 AND E<A+19 AND R< 25 AND R > 24 THEN T = 4: P = .9
IF E>A+19 AND E<A+20 AND R<25 AND R > 24 THEN T = 4: P = .01

IF T = 3 THEN R = R + I * D: E = E - P
IF T = 4 THEN R = R + I * D: E = E + P
IF T = 5 THEN R = R + I * D
IF E < 0 AND T = 3 THEN T = 4
IF E > 299 AND T = 4 THEN T = 3
IF E > 299 AND T = 2 THEN T = 1
Y = INT(RND * 20) + 1
'pallon nopeus
IF A > E - Y THEN A = A - .2 * D
IF A < E - 20 + Y THEN A = A + .2 * D

IF A < 0 THEN A = A + 1
IF A > 299 THEN A = A - 1

' laskee pelaajan pisteet
IF R < -5 THEN player = player + 1: CLS 1: GOTO 0

'laskee CPU:n pisteet
IF R > 200 THEN computer = computer + 1: CLS 1: GOTO 0
IF player = B THEN GOTO Victory
IF computer = B THEN GOTO lose
'tähän päättyy jossittelu
' näyttää CPU:n pisteet
LOCATE 1, 1: PRINT "CPU points: "; computer
' näyttää pelaajan pisteet
LOCATE 1, 22: PRINT "Your points: "; player
LOOP
Victory:
CLS
LOCATE 5,9: PRINT "Voitit erän"; player; "-"; computer; ""
SLEEP
END
lose:
LOCATE 5,9: PRINT "Hävisit erän"; player; "-"; computer; ""
SLEEP

rndprogy [23.09.2003 18:30:14]

#

No onko kommentoitavaa? Palautetta.

Vastaus

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

Tietoa sivustosta