Posts: 77
Threads: 15
Joined: Mar 2004
This should be fun. I'll try it, too. No libs and try to make it graphical; text games are rarely fun. Post here to enter, the best one wins (by best, I mean most fun).
nd remember kids, only you can provoke forest fires!
Posts: 2,765
Threads: 138
Joined: Nov 2002
ok, i guess ill try
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 6,419
Threads: 74
Joined: Mar 2002
Do you mean something like this?
Code: ' Compile w/ ffix for maximum performance.
DECLARE SUB Advance (GfxObj AS ANY)
DECLARE SUB ObjDraw (GfxObj AS ANY, Tri() AS ANY)
DECLARE FUNCTION FindEmptyIndex% (Array() AS ANY)
PRINT "Easy PQB Asteroids (C) 28/6/2003 by Na Than Assh Antti."
PRINT "Coded in 1 hour, probably slow (SCREEN 7 stuff)."
PRINT : PRINT "Keys: LEFT CTRL and ALT: Rotate left and right."
PRINT " LEFT SHIFT: Advance."
PRINT " RIGHT SHIFT: Fire."
PRINT : PRINT "Any key to play..."
SLEEP: k$ = INKEY$
CONST PI = 3.141516916#
TYPE ObjectData
x AS SINGLE
y AS SINGLE
v AS SINGLE
angle AS SINGLE
state AS INTEGER
radius AS SINGLE
END TYPE
TYPE Points
x AS SINGLE
y AS SINGLE
END TYPE
' Define our ship (triangle). It is centered in the origin:
DIM GfxShip(2) AS Points
GfxShip(0).x = 5: GfxShip(0).y = 0
GfxShip(1).x = -5: GfxShip(1).y = 5
GfxShip(2).x = -5: GfxShip(2).y = -5
' Asteroids:
DIM GfxAst0(6) AS Points
DIM GfxAst1(6) AS Points
DIM GfxAst2(6) AS Points
' Big asteroid:
GfxAst0(0).x = 17: GfxAst0(0).y = 0
GfxAst0(1).x = 5: GfxAst0(1).y = 12
GfxAst0(2).x = -8: GfxAst0(2).y = 7
GfxAst0(3).x = -19: GfxAst0(3).y = -1
GfxAst0(4).x = -5: GfxAst0(4).y = -4
GfxAst0(5).x = -2: GfxAst0(5).y = -13
GfxAst0(6).x = 3: GfxAst0(6).y = -4
' Mid asteroid:
FOR i% = 0 TO 6
GfxAst1(i%).x = GfxAst0(i%).x * .75
GfxAst1(i%).y = GfxAst0(i%).y * .75
NEXT i%
' Small asteroid:
FOR i% = 0 TO 6
GfxAst2(i%).x = GfxAst0(i%).x * .5
GfxAst2(i%).y = GfxAst0(i%).y * .5
NEXT i%
DIM MyShip AS ObjectData
MyShip.x = 160
MyShip.y = 100
MyShip.v = 2
MyShip.angle = 0!
DIM Asteroids(100) AS ObjectData
FOR i% = 0 TO 9
Asteroids(i%).x = INT(RND * 320)
Asteroids(i%).y = INT(RND * 200)
Asteroids(i%).v = RND * 3 + 1
Asteroids(i%).angle = RND * PI
Asteroids(i%).radius = 12
Asteroids(i%).state = 0 ' Big asteroids
NEXT i%
FOR i% = 10 TO 100
Asteroids(i%).state = -1 ' Not used
NEXT i%
DIM Shoots(3) AS ObjectData
FOR i% = 0 TO 3: Shoots(i%).state = -1: NEXT i%
SCREEN 7, , 1, 0
DEF SEG = 0
FirePressed% = 0
Score% = 0
FlipFlop% = 0
FirstTime% = -1
WHILE INP(&H60) <> 1
' Create Asteroids?
IF (Score% > 0 AND (Score% MOD 2100 = 0)) OR FirstTime% THEN
FirstTime% = 0
FOR i% = 0 TO 9
Asteroids(i%).x = INT(RND * 320)
Asteroids(i%).y = INT(RND * 200)
Asteroids(i%).v = RND * 3 + 1
Asteroids(i%).angle = RND * PI
Asteroids(i%).radius = 12
Asteroids(i%).state = 0 ' Big asteroids
NEXT i%
FOR i% = 10 TO 100
Asteroids(i%).state = -1 ' Not used
NEXT i%
END IF
k$ = INKEY$ ' clear buffer
' Move Player:
IF PEEK(1047) AND 4 THEN
MyShip.angle = MyShip.angle - .1: IF MyShip.angle < 0 THEN MyShip.angle = 2 * PI
END IF
IF PEEK(1047) AND 8 THEN
MyShip.angle = MyShip.angle + .1: IF MyShip.angle > 2 * PI THEN MyShip.angle = 0
END IF
IF PEEK(1047) AND 2 THEN Advance MyShip
IF PEEK(1047) AND 1 THEN
IF NOT FirePressed% THEN
idx% = FindEmptyIndex%(Shoots())
IF idx% <> -1 THEN
Shoots(idx%).state = 0
Shoots(idx%).x = MyShip.x
Shoots(idx%).y = MyShip.y
Shoots(idx%).angle = MyShip.angle
Shoots(idx%).v = 4
END IF
END IF
FirePressed% = -1
ELSE
FirePressed% = 0
END IF
IF MyShip.x < 0 THEN MyShip.x = 319
IF MyShip.x > 319 THEN MyShip.x = 0
IF MyShip.y < 0 THEN MyShip.y = 199
IF MyShip.y > 199 THEN MyShip.y = 0
' Move Asteroids
FOR i% = 0 TO 100
FlipFlop% = NOT -ABS(SGN(FlipFlop%)) ' Flip the Flop.
IF Asteroids(i%).state <> -1 THEN
IF FlipFlop% THEN Advance Asteroids(i%)
IF Asteroids(i%).x < 0 THEN Asteroids(i%).x = 319
IF Asteroids(i%).x > 319 THEN Asteroids(i%).x = 0
IF Asteroids(i%).y < 0 THEN Asteroids(i%).y = 199
IF Asteroids(i%).y > 199 THEN Asteroids(i%).y = 0
' Collisions:
' 1.- With shoots
FOR j% = 0 TO 3
' Lame square checking (may this change??)
IF Shoots(j%).state <> -1 THEN
IF Shoots(j%).x > Asteroids(i%).x - Asteroids(i%).radius THEN
IF Shoots(j%).x < Asteroids(i%).x + Asteroids(i%).radius THEN
IF Shoots(j%).y > Asteroids(i%).y - Asteroids(i%).radius THEN
IF Shoots(j%).y < Asteroids(i%).y + Asteroids(i%).radius THEN
Shoots(j%).state = -1
' Break Asteroid:
IF Asteroids(i%).state < 2 THEN
mySt% = Asteroids(i%).state
xx% = Asteroids(i%).x
yy% = Asteroids(i%).y
vv! = Asteroids(i%).v
a! = Asteroids(i%).angle
Asteroids(i%).state = -1
idx1% = FindEmptyIndex%(Asteroids())
IF idx1% <> -1 THEN
Asteroids(idx1%).state = mySt% + 1
Asteroids(idx1%).x = xx%
Asteroids(idx1%).y = yy%
Asteroids(idx1%).v = vv!
Asteroids(idx1%).angle = a! + PI / 2
IF (mySt% + 1) = 1 THEN
Asteroids(idx1%).radius = 10
ELSE
Asteroids(idx1%).radius = 7
END IF
END IF
idx2% = FindEmptyIndex%(Asteroids())
IF idx2% <> -1 THEN
Asteroids(idx2%).state = mySt% + 1
Asteroids(idx2%).x = xx%
Asteroids(idx2%).y = yy%
Asteroids(idx2%).v = vv!
Asteroids(idx2%).angle = a! - PI / 2
IF (mySt% + 1) = 1 THEN
Asteroids(idx2%).radius = 10
ELSE
Asteroids(idx2%).radius = 7
END IF
END IF
Score% = Score% + 2 * (mySt% + 1)
ELSE
Asteroids(i%).state = -1 ' Break!
Score% = Score% + 50
END IF
END IF
END IF
END IF
END IF
END IF
NEXT j%
' 2.- With player
IF MyShip.x > Asteroids(i%).x - Asteroids(i%).radius THEN
IF MyShip.x < Asteroids(i%).x + Asteroids(i%).radius THEN
IF MyShip.y > Asteroids(i%).y - Asteroids(i%).radius THEN
IF MyShip.y < Asteroids(i%).y + Asteroids(i%).radius THEN
SCREEN 7, , 0, 0
t$ = "FINAL SCORE:" + STR$(Score%)
LOCATE 12, 20 - LEN(t$) \ 2: PRINT t$
WHILE k$ <> INKEY$: WEND
SLEEP: k$ = INKEY$
FirstTime% = -1: Score% = 0
SCREEN 7, , 1, 0
END IF
END IF
END IF
END IF
END IF
NEXT i%
' Move Shoots
FOR i% = 0 TO 3
IF Shoots(i%).state <> -1 THEN
Advance Shoots(i%)
IF Shoots(i%).x < 0 OR Shoots(i%).x > 319 OR Shoots(i%).y < 0 OR Shoots(i%).y > 199 THEN Shoots(i%).state = -1
END IF
NEXT i%
' Render:
LINE (0, 0)-(319, 199), 0, BF
ObjDraw MyShip, GfxShip()
FOR i% = 0 TO 100
SELECT CASE Asteroids(i%).state
CASE 0:
ObjDraw Asteroids(i%), GfxAst0()
CASE 1:
ObjDraw Asteroids(i%), GfxAst1()
CASE 2:
ObjDraw Asteroids(i%), GfxAst2()
END SELECT
NEXT i%
FOR i% = 0 TO 3
IF Shoots(i%).state <> -1 THEN
PSET (Shoots(i%).x, Shoots(i%).y), 15
END IF
NEXT i%
LOCATE 1, 1: PRINT Score%
WAIT &H3DA, 8, 8: WAIT &H3DA, 8
PCOPY 1, 0
WEND
SUB Advance (GfxObj AS ObjectData)
GfxObj.x = GfxObj.x + GfxObj.v * COS(GfxObj.angle)
GfxObj.y = GfxObj.y + GfxObj.v * SIN(GfxObj.angle)
END SUB
FUNCTION FindEmptyIndex% (Array() AS ObjectData)
res% = -1
FOR i% = 0 TO UBOUND(Array)
IF Array(i%).state = -1 THEN res% = i%: EXIT FOR
NEXT i%
FindEmptyIndex% = res%
END FUNCTION
SUB ObjDraw (GfxObj AS ObjectData, Tri() AS Points)
' Draws a rotated closed polygon. It uses the typlica matrix transform
' for 2D
oldxx% = 0: oldyy% = 0
FOR i% = 0 TO UBOUND(Tri)
' Rotate points
xx% = INT(Tri(i%).x * COS(GfxObj.angle) - Tri(i%).y * SIN(GfxObj.angle))
yy% = INT(Tri(i%).x * SIN(GfxObj.angle) + Tri(i%).y * COS(GfxObj.angle))
IF i% > 0 THEN
LINE (GfxObj.x + oldxx%, GfxObj.y + oldyy%)-(GfxObj.x + xx%, GfxObj.y + yy%)
ELSE
' First point: no line to draw. Instead, we remember it to
' close the polygon after the loop ends.
initxx% = xx%: inityy% = yy%
END IF
oldxx% = xx%
oldyy% = yy%
NEXT i%
LINE (GfxObj.x + oldxx%, GfxObj.y + oldyy%)-(GfxObj.x + initxx%, GfxObj.y + inityy%)
END SUB
Obviously this doesn't qualify, 'cause it is not a two player game. But I mean: Do you want simple games which source code is less than 5 Kb?
If so, maybe I give it a try. Coding something in just 30 minutes is fun
Posts: 77
Threads: 15
Joined: Mar 2004
Yeah, keep it simple. Source code must be under 5 kb. Hmm... maybe that's to much.
nd remember kids, only you can provoke forest fires!
Posts: 3,616
Threads: 287
Joined: Jan 2003
When does this challenge expire? I'm working on something else right now, but I'd like to give 'er a shot.
(thinks about space shooters...)
And text games are rarely fun? I strongly disagree.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 77
Threads: 15
Joined: Mar 2004
Quote:When does this challenge expire? I'm working on something else right now, but I'd like to give 'er a shot.
(thinks about space shooters...)
And text games are rarely fun? I strongly disagree.
It shouldn't take very much time for people to finish their entries, so I'll just wait for everyone to finish. Unless of course they take way to much time. Just hurry up and finish whatever you're doing, and then do this.
Text games are rarely fun, but not always. Some of them are pretty cool but most are kinda boring.
nd remember kids, only you can provoke forest fires!
Posts: 2,765
Threads: 138
Joined: Nov 2002
Quote:Text games are rarely fun, but not always. Some of them are pretty cool but most are kinda boring.
im insulted.... i like making text games (mainly becuase i stink at everything else =P)
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 142
Threads: 6
Joined: Aug 2001
Quote:im insulted.... i like making text games (mainly becuase i stink at everything else =P)
I enjoy making text games as well. But not the type you two are thinking of. I like making parsers for handling interactive fiction (like Zork) games.
When it comes to this challenge I can see three possible entries. First and most obvious would be pong. Second would be space invaders. And third would be tetris.
Posts: 58
Threads: 6
Joined: Jun 2004
Hello. I am sorta a QBASIC newbie. I have been working on it for a while. most of my games and simulations are under 5kb. here is an example.
Code: ü Ââ Qÿÿ$ ÿÿÃf  <5 ]] n t Ë â à z ¤ ² â¬x V Ë Â Ã Ã Ã» ò à ÃR ž Keyâ speed« delaq pxj py upk dnk¸ x½ y¿ xs* ys erã ere ewr# pc cir lin oly
olxé size· por wec starx stary starz thQ olsxK olsyC starcW der starnum rix riy dere bx by dw rtÅ try§ bxs bysâ¡ bolxŽ boy box boly Oh mathew3¯ riy2 rix2 ty tyt } eè é }$ eè ò }6 eè û }H eè F V sdsdà m- Press the up key you want for this pong game."â V z V m qc N F V sdsdà m/ Press the down key you want for this pong game."â V  V m qc ¼ se
ç d ] e2 * k Ã? j d q e K ed Q d Ë ed  d â d Ë d ² e- à d *V ÿÿH Ce@p&n é Ceà p&n ò Cdpn û Cdp&ne f ÿÿ F V â 51 56 d *V ÿÿ¨ #d û dpnd V ÿÿ
5 é û dwnpn < ò û dwnpn  #d #f ÿÿ ed û k
ã<wned pnw § e û k
ã<wne pnw ¯ ed û ed pnw < e û e pnw 5 é
ò û dcna û ] f â n û I ò Cdd V ÿÿ¤ #ddV Ã¿Ã¿Ë 5 é û pn < ò û pn  #d #f ÿÿ Cf ÿÿ d û Ce@p&n é Ceà p&n ò P # û dpn û dpnd V ÿÿ⬠5 é û pn < ò û pn  #d #f ÿÿ #d û dpnd V ÿÿ ¯ é û k
ã<wnpn § ò û k
ã<wnpn  #d #f ÿÿ #d û dpnV ÿÿŠ5 é û pn < ò û pn  #  #f ÿÿ f ÿÿ sdsdà ] &⢠m <--speed."â V z na Ë k ?w Ë V  nM ( Ë k ? Ë P Â Ã Ë Ã Ë â Ë Â Ë Â Ë d_na Å Ë kÃÃL=w Ë Ë dcnM ® Ë kÃÃL= Ë P  eà à d nw_na
e e w Ë d w Ë eà à d nw   dcnM 6 d Ë d w Ë d  P â
8*>**>*>*
> Ke ^na ¶ jd_na Šjk
Ã#<w j jdbnM ° jkpÃË<w j P Ke b Ke _nM ¸ Q  d)wn^  à d) n Q^na ² e e w jw j jkÅ¡â¢Ã?_na B kÅ¡â¢Ã? j P jdcna ^ d j P qd
c qd
x_na Å q Ë k Ã?n q I ® qd q P P Ke b Kd^nM N
Q Â ^ Q Â Ã nbna J
k @? j qd
c qd
x_na 4
Ë q I F
qd q P P P Qeà _na x
d qw q QdcnM ¢
e e w qw q P K â¡ Q ⬠K j K Q q Q ã de V ÿÿ8 à ã n à d!wn à ã nd! à à n Æ d¼ ã f ÿÿ ¿ dd)V ÿÿ¨ Ë d ¿ n  d nÂ Ë d ¿ n  à dwn Æ Â¿ e ¼ ¿ f ÿÿ ¸ ddV ÿÿ" ¸ d_na ú Ë d n   ¸ e ¸ wn I Ë d n   ¸ d P ¸ f ÿÿ ¸ ddV ÿÿ¬ ¸ d_na | Ë d n  à n ¸ e ¸ wn I ¢ Ë d n  à n ¸ d P ¸ f ÿÿ ] e cna à ] kÂÃõ< ] ] ex ^nM
] k ? ] ] e ^nM .
] kÃÃÃ= ] P â
9* Wde V ÿÿn
â¡ â¬Â Wd Wf ÿÿ Wde d W ÿÿ¸
K QÂ WCd
p&ne5  Wf ÿÿ â¡ â¬Â cd ck ? c K Q cCe p&n ce _na > K Q cd d c P WddV ÿÿ¬ Ce¸p&n ] ]eà _na ~ I ¢ K Q We Ww P Wf ÿÿ â
9* ] eÃ^na â m q"V s£ ·de@V ÿÿ> ½deà V ÿÿ2 · ½ Ce p&nà ½f ÿÿ ·f ÿÿ m You won!â F sdsdà m Press Q to end the game.â m q"c T P f dd)eà ] &wnpV ÿÿà dd dà f f ÿÿ Kdxcna ø m q"V P V m q"c P ÿÿÿÿÿÿÿÿõ 3
it is unreadable because I used a form of qbasic that.... encripts it or something when I save it. you will have to run it in that one. It is a no sound space pong game. the graphics are pretty cool, and the effects of hyper-space are awesome! I gtg now.[/code]
Posts: 2,765
Threads: 138
Joined: Nov 2002
er you are using qb4.5 I think
well in the save box click the radio button that says text mode or soemthing That saves it as a readable format
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
|