Qbasicnews.com
EDIT: Make a game in 10 lines or less. - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QbasicNews.Com (http://qbasicnews.com/newforum/forum-3.html)
+--- Forum: Challenges (http://qbasicnews.com/newforum/forum-10.html)
+--- Thread: EDIT: Make a game in 10 lines or less. (/thread-3420.html)

Pages: 1 2 3 4 5


EDIT: Make a game in 10 lines or less. - PlayGGY - 03-09-2004

Quote:heh was that supposed to be a joke?!?!? lol.


but anyways, you could make the code shorter by changing all the double numbers.

ie change (pX - 1 - 23) to (pX - 24)
PlayGGY Wrote:Here:
Code:
7 : IF ((bX >= pX - 1 - 23) AND (bX <= (pX + 6 - 23)) AND (bY = 63 - 2)) OR (bY = 1 - 2) THEN bS = bS + -((bS AND 2) - 1) * 2

Yeah, I could, but that would make ever going back and changing where the ball starts, or how long the paddle is, or where the game is centered in the screen, etc. impossible,

I will go ahead and do that, but I'll keep the original code so I could more easily change that stuff. I'll post it in a few minutes.

EDIT: Yes, I was joking about it being good code... it really is the nastiest code I have ever seen.


EDIT: Make a game in 10 lines or less. - PlayGGY - 03-09-2004

Okay, here is the code with the math simplified (there goes any hope of anyone else understanding it) Sad:

Code:
1 : SCREEN 13
2 : IF INP(96) = 57 THEN pX = pX - -(pX > 1) ELSE pX = pX + -(pX < 39)
3 : DRAW "c0 bm" + STR$(pX + 135) + ",130 r7 bm" + STR$(bX + 158) + "," + STR$(bY + 67) + "f2 bm" + STR$(bX + 160) + "," + STR$(bY + 67) + "g2 c1 bm136,66 r45 d65 l45 u64 c2 bm" + STR$(pX + 136) + ", 130 r5 c4 bm" + STR$(bX + 159) + "," + STR$(bY + 68) + "r0"
4 : bX = bX + ((bS AND 1) * 2) - 1
5 : bY = bY + (bS AND 2) - 1
6 : IF bX <= -22 OR bX >= 21 THEN bS = bS + -(((bS AND 1) * 2) - 1)
7 : IF ((bX >= pX - 24) AND (bX <= (pX - 17)) AND (bY = 61)) OR (bY = -1) THEN bS = bS + -((bS AND 2) - 1) * 2
8 : time = TIMER
9 : IF time = TIMER AND ((dummy$ = INKEY$) OR 1) THEN GOTO 9
10 : IF (bY < 63) THEN GOTO 2 ELSE PRINT "                You lose"

'10 line "Wall" pong.  Made by Daniel Miller.
'Controls:  Hold space bar to move to the left.
'           Let go to move to the right.
'Features:  No flicker
'           No keyboard "clicks"
'           Goes the same speed on every computer



EDIT: Make a game in 10 lines or less. - Frobozz - 03-09-2004

Well this sucks... I go to try it only to find out VBDos can't handle the lines because they are too long. Sad


EDIT: Make a game in 10 lines or less. - PlayGGY - 03-09-2004

Do you need a link to QB? Or, you can try the most recent one I put up, with shortened lines.


EDIT: Make a game in 10 lines or less. - Bluffer - 03-09-2004

Them were cool games I really think you guys done great..
I am amazed at what yuns done in only 10 to 11 lines


I am still learning Smile


EDIT: Make a game in 10 lines or less. - oracle - 03-09-2004

This reminds me of a challenge a while ago:

Code:
DO
  INPUT "Ready? ", key$
  IF RND THEN PRINT "Player 1 wins!" ELSE PRINT "Player 2 wins!"
LOOP UNTIL key$ = CHR$(27)

:lol:


EDIT: Make a game in 10 lines or less. - Zack - 03-09-2004

Quote:This reminds me of a challenge a while ago:

Code:
DO
  INPUT "Ready? ", key$
  IF RND THEN PRINT "Player 1 wins!" ELSE PRINT "Player 2 wins!"
LOOP UNTIL key$ = CHR$(27)

:lol:
That game gives Player 1 an unfair advantage - very rarely with RND return 0.


EDIT: Make a game in 10 lines or less. - oracle - 03-09-2004

Oops, I meant INT(RND) Wink


EDIT: Make a game in 10 lines or less. - LooseCaboose - 03-09-2004

Space invaders clone in 15 lines (I might work on it some more and try and cut it down a few). There are only five enemies in a single line and they cant shoot back, so the game is quite easy. The game uses double buffered screen 7 graphics, has sound and gets harder as the game progresses. Once again, the game wont end if you win, but it will if you lose.

Controls:
Z - move left
X - move right
Enter - Shoot
Esc - Quit

Code:
1 FOR i = 0 TO 22
2 IF i = 0 THEN SCREEN 7 ELSE IF i = 1 THEN px = 160 ELSE IF i = 2 THEN sy = -5 ELSE IF i  = 3 THEN edir = 1 ELSE IF i = 4 THEN DIM ex(0 TO 5), ey(0 TO 5), ea(0 TO 5) ELSE IF i = 5 THEN d = 5
3 IF i = 5 THEN ey(0) = 10 ELSE IF i = 6 THEN ey(1) = 10 ELSE IF i = 7 THEN ey(2) = 10 ELSE IF i = 8 THEN ey(3) = 10 ELSE IF i = 9 THEN ey(4) = 10 ELSE IF i = 10 THEN ey(5) = 10 ELSE IF i = 11 THEN e(0) = 40 ELSE IF i = 12 THEN ex(1) = 80 ELSE IF i = 13 THEN ex(2) = 120 ELSE IF i = 14 THEN ex(3) = 160 ELSE IF i = 15 THEN ex(4) = 200 ELSE IF i = 16 THEN ex(5) = 240 ELSE IF i = 17 THEN ea(0) = 0 ELSE IF i = 18 THEN ea(1) = 1 ELSE IF i = 19 THEN ea(2) = 1 ELSE IF i = 20 THEN ea(3) = 1 ELSE IF i = 21 THEN ea(4) = 1 ELSE IF i = 2 THEN ea(5) = 1
4 NEXT
5 FOR k = 0 TO 14
6 IF k = 0 THEN SCREEN 7, , 1, 0 ELSE IF k = 1 THEN PCOPY 2, 1 ELSE IF k = 2 THEN IF sy = 175 THEN sx = px ELSE ambiguity = 1 ELSE IF k = 3 THEN IF sy <> -5 THEN sy = sy - 5 ELSE ambiguity = 1 ELSE IF k = 4 THEN DRAW "C10BM=" + VARPTR$(px) + ",180F10L20E10BD5P10,10"
7 IF k < 6 THEN GOSUB drawEnemy ELSE IF k = 7 AND INP(96) = 44 AND px > 20 THEN px = px - 5 ELSE IF k = 8 AND INP(96) = 45 AND px < 300 THEN px = px + 10 ELSE IF k = 9 AND INP(96) = 28 AND sy = -5 THEN sy = 175 ELSE IF k = 10 AND INP(96) = 1 THEN END
8 IF k = 6 AND POINT(sx, sy) = 13 THEN SOUND 100, 1 ELSE IF k = 7 AND POINT(sx, sy) = 13 THEN e = (sx - ex(0)) / 40 ELSE IF k = 8 AND POINT(sx, sy) = 13 THEN ea(e) = 0 ELSE IF k = 9 THEN PSET(sx, sy), 12 ELSE IF k = 10 THEN PCOPY 1, 0 ELSE IF k = 11 THEN SCREEN 7, , 0, 0 ELSE IF k = 12 THEN time = TIMER ELSE IF k = 13 AND TIMER < time THEN GOTO 8 ELSE IF k = 14 THEN GOTO 5
9 NEXT
10 changeDir: FOR i = 0 TO 9
11 IF i = 0 THEN IF edir = 1 THEN edir = 2 ELSE edir = 1 ELSE IF i = 1 THEN ey(0) = ey(0) + d ELSE IF i = 2 THEN ey(1) = ey(1) + d ELSE IF i = 3 THEN ey(2) = ey(2) + d ELSE IF i = 4 THEN ey(3) = ey(3) + d ELSE IF i = 5 THEN ey(4) = ey(4) + d ELSE IF i = 6 THEN ey(5) = e(5) + d ELSE IF i = 7 THEN IF ey(0) >= 170 THEN END ELSE ambiguity = 1 ELSE IF i = 8 THEN d = d + 2 ELSE IF i = 9 THEN RETURN
12 NEXT
13 drawEnemy: FOR j = 0 TO 7
14 IF j = 0 THEN kx = ex(k) ELSE IF j = 1 THEN ky = ey(k) ELSE IF j = 2 THEN IF ea(k) = 1 THEN DRAW "C13BM=" + VARPTR$(kx) + ",=" + VARPTR$(ky) + "F5G10E10H5G5F10H5BU5P13,13" ELSE ambiguity = 1 ELSE IF j = 3 THEN IF edir = 1 AND ex(0) < 100 THEN ex(k) = ex(k) + 1 ELSE ambiguity = 1 ELSE IF j = 4 THEN IF edir = 1 AND ex(0) >= 100 THEN GOSUB changeDir ELSE ambiguity = 1 ELSE IF j = 5 THEN IF edir = 2 AND ex(0) > -20 THEN ex(k) = ex(k) - 1 ELSE ambiguity = 1 ELSE IF j = 6 THEN IF edir = 2 AND ex(0) <= -20 THEN GOSUB changeDir ELSE ambiguity = 1 ELSE IF j = 7 THEN RETURN
15 NEXT



EDIT: Make a game in 10 lines or less. - KiZ - 03-09-2004

Quote:This reminds me of a challenge a while ago:

Code:
DO
  INPUT "Ready? ", key$
  IF RND THEN PRINT "Player 1 wins!" ELSE PRINT "Player 2 wins!"
LOOP UNTIL key$ = CHR$(27)

:lol:

haha.. lmao

Quite some game oracle heh heh he ;D