Qbasicnews.com

Full Version: Challenge....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Code:
'balls by Antoni Gual    agual@eic.ictnet.es
1  IF p% >= 16 THEN 3 ELSE IF p% = 0 THEN SCREEN 12 ELSE PALETTE p% - 1, b&
2  READ p%, b&
3  IF p% < 16 THEN GOTO 9 ELSE a$ = MKI$(RND * 640 + 1) + MKI$(RND * 480) + MKS$((RND * 60) + 20) + MKI$(INT(RND * 4) * 4) + MKS$(RND * 3.141592) + MKS$(RND * 3.141592 / 1.5)
4 FOR i% = -INT(CVS(MID$(a$, 5))) TO INT(CVS(MID$(a$, 5)))
5  FOR j% = -INT(SQR(CVS(MID$(a$, 5)) ^ 2 - i% ^ 2)) TO INT(SQR(CVS(MID$(a$, 5)) ^ 2 - i% ^ 2))
6   c! = 3 * (COS(CVS(MID$(a$, 11))) * SIN(CVS(MID$(a$, 15))) * i% / CVS(MID$(a$, 5)) + SIN(CVS(MID$(a$, 11))) * SIN(CVS(MID$(a$, 15))) * j% / CVS(MID$(a$, 5)) + COS(CVS(MID$(a$, 15))) * SQR(1.11 - (i% / CVS(MID$(a$, 5))) ^ 2 - (j% / CVS(MID$(a$, 5) _
)) ^ 2))
7   PSET (CVI(MID$(a$, 1)) + i%, CVI(MID$(a$, 3)) + j%), 1 + CVI(MID$(a$, 9)) + INT(c!) + (RND > (c! - INT(c!)))
8 NEXT j%, i%
9 IF LEN(INKEY$) = 0 THEN GOTO 1 ELSE DATA 1,&h5,2,&h10,3,&h20,4,&h30,5,&h500,6,&h1000,7,&h2000,8,&h3000,9,&h50000,10,&h100000,11,&h200000,12,&h300000,13,&h50505,14,&h101010,15,&h202020,16,&h303030,17,0
egad. this filler challenge has become quite a phenomena. i dont think toshi's had this many entry (well, after the fourth one that happened but you get the idea)
Code:
1 SCREEN 13
2 DIM ballx(50), bally(50), ballxv(50), ballyv(50)
3 i = (i + 1) MOD 50
4 IF ballx(i) = 0 THEN ballx(i) = RND * 320 ELSE IF bally(i) = 0 THEN bally(i) = RND * 320
5 IF ballxv(i) = 0 THEN ballxv(i) = RND * 10 - 5 ELSE IF ballyv(i) = 0 THEN ballyv(i) = RND * 10 - 5
6 IF (ballx(i) >= 320 AND ballxv(i) > 0) OR (ballx(i) <= 1 AND ballxv(i) < 0) THEN ballxv(i) = -ballxv(i) ELSE ballx(i) = ballx(i) + ballxv(i)
7 IF (bally(i) >= 200 AND ballyv(i) > 0) OR (bally(i) <= 1 AND ballyv(i) < 0) THEN ballyv(i) = -ballyv(i) ELSE bally(i) = bally(i) + ballyv(i)
8 CIRCLE (ballx(i), bally(i)), (TIMER / 16) MOD (i + 1), i MOD 15 + 16
9 IF INKEY$ = "" THEN GOTO 3
:bounce: :bounce: :bounce: :bounce:
A cheap-o way to do a cheap-o fire effect in 8 lines.

Code:
1 FOR t = -1 TO 64
2   IF t = -1 THEN SCREEN 13 ELSE IF t = 64 THEN LINE (0, 189)-(319, 199), 60, BF ELSE PALETTE t, t
3 NEXT
4 FOR y% = 169 TO 189
5 FOR x% = 0 TO 319
6 IF x% = 319 AND y% = 189 THEN GOTO 4 ELSE c% = POINT(x%, y%) - RND * 8
7 IF c% >= 0 THEN PSET (x%, y% - 1), c% ELSE IF INKEY$ <> "" THEN END
8 NEXT x%, y%

You could change it easy to fill up the screen, but it would soooo slow.

Change the 169 in line 4 to a lower number, and the * 8 in line 6 to a lower number as well.

- Dav
if/then/else is *such* a cheap hack Tongue but it's definately faster than mine...
Ack, guys, I just couldn't help myself...

6-line Rotozoomer:

Code:
SCREEN 13
1  ang = ang + .08725
scale = scale + (SGN(SIN(ang)) / 10)
2 p& = (p& + 1) AND 65535
PSET (p& MOD 320, (p& - (p& MOD 320)) \ 320), (((((p& MOD 320) - 160) * COS(ang) - (((p& - (p& MOD 320)) / 320) - 100) * SIN(ang)) * scale) AND 63) OR ((((((p& - (p& MOD 320)) / 320) - 100) * COS(ang) + ((p& MOD 320) - 160) * SIN(ang)) * scale) AND  _
63)
IF p& = 65535 THEN GOTO 1 ELSE GOTO 2

Meh, could be a lot better. Maybe someone should do a text-mode version :)
text mode graphic demos are always fun Smile

here, i seriously cleaned up my fire demo, and it runs a bajillion (i've confirmed this with tests) times faster. no funky tricks either

Code:
1 SCREEN 13
2 FOR x% = 0 TO 127
3 PALETTE x%, x% \ 2
4 NEXT x%
5 DEF SEG = &HA7D0
6 FOR x% = 31999 TO 0 STEP -1
7 IF x% >= 31680 THEN POKE x%, CINT(RND * 127) ELSE POKE x%, (PEEK(x% + 320) + PEEK(x% + 319) + PEEK(x% + 321) + PEEK(x%) + PEEK(x% + 640)) \ 5
8 NEXT x%
9 IF INKEY$ = "" THEN GOTO 5
Cool one! Smile

- Dav
Im trying to make a decent one, my first one (7 lines) is funny lol, it sucks i think.. quite random.. im not gonna post it Wink.

(DAMNIT) Whats left to make? someone gimmi an idea?

(edit).. I decided to make a 3d rotating pyramid, LOL, here it (hopefully) is:
(edit).. Damnit i mistyped a number, oops, now it works.

Code:
1 SCREEN 13
2 LINE (160, 90)-((SIN(((TIMER * 10) MOD 360) * 3.1415 / 180) * 150) / (COS(((TIMER * 10) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 160, 50 / (COS(((TIMER * 10) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 150)
3 LINE (160, 90)-((SIN(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 150) / (COS(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 160, 50 / (COS(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 150)
4 LINE (160, 90)-((SIN(((((TIMER * 10) MOD 360) + 240) MOD 360) * 3.1415 / 180) * 150) / (COS(((((TIMER * 10) MOD 360) + 240) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 160, 50 / (COS(((((TIMER * 10) MOD 360) + 240) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 150)
5 LINE ((SIN(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 150) / (COS(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 160, 50 / (COS(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 150)-((SIN(((TIMER * 10) MOD 360) * 3.1415 / 180) * 150) / (COS(((TIMER * 10) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 160, 50 / (COS(((TIMER * 10) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 150)
6 LINE -((SIN(((((TIMER * 10) MOD 360) + 240) MOD 360) * 3.1415 / 180) * 150) / (COS(((((TIMER * 10) MOD 360) + 240) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 160, 50 / (COS(((((TIMER * 10) MOD 360) + 240) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 150)
7 LINE -((SIN(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 150) / (COS(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 160, 50 / (COS(((((TIMER * 10) MOD 360) + 120) MOD 360) * 3.1415 / 180) * 40 + 150) * 64 + 150)
8 CLS
9 GOTO 2
Kewl!!!!!

I have made 3 fx here last night.

1. A 3d(no hacks) rotating sphere

2. a rotozoomer(but Generic beat me to it)

3. A raycaster..... Yes, but its still 13 lines long. :*(

Here's the 3d rotator. I could add some camera action but its slow already...


Code:
'Relsoft presents.... The Sphere 2003
'Could've made this 7 lines but darn QB!!! it won't let me cut 'n paste
'properly... ;*(

1 IF RotX = 0 THEN SCREEN 12 ELSE A! = (A! + .04) * -(A! < 6.283186)
2 FOR S% = 1 TO 11
3 FOR P% = 1 TO 20
4 RotX! = (((140 * SIN(3.141593 / 11 * S%) * SIN(6.283186 / 20 * P%))) * (COS(A!) * COS(A!)) + ((140 * SIN(3.141593 / 11 * S%) * COS(6.283186 / 20 * P%))) * (COS(A!) * -SIN(A!) + SIN(A!) * SIN(A!) * COS(A!)) + ((140 * COS(3.141593 / 11 * S%))) * (- _
SIN(A!) * -SIN(A!) + COS(A!) * SIN(A!) * COS(A!)))
5 RotY! = (((140 * SIN(3.141593 / 11 * S%) * SIN(6.283186 / 20 * P%))) * (COS(A!) * SIN(A!)) + ((140 * SIN(3.141593 / 11 * S%) * COS(6.283186 / 20 * P%))) * (COS(A!) * COS(A!) + SIN(A!) * SIN(A!) * SIN(A!)) + ((140 * COS(3.141593 / 11 * S%))) * (- _
SIN(A!) * COS(A!) + COS(A!) * SIN(A!) * SIN(A!)))
6 IF ((((140 * SIN(3.141593 / 11 * S%) * SIN(6.283186 / 20 * P%))) * (-SIN(A!)) + ((140 * SIN(3.141593 / 11 * S%) * COS(6.283186 / 20 * P%))) * (SIN(A!) * COS(A!)) + ((140 * COS(3.141593 / 11 * S%))) * (COS(A!) * COS(A!)))) <= 0 THEN PSET ((256 *  _
RotX! / (256)) + 320, -(256 * RotY! / (256)) + 240), ((S% + P%) AND 15) + 1
7 NEXT P%, S%
8 LINE (0, 0)-(639, 479), 0, BF
9 IF INKEY$ = "" THEN 1

B4 I go, it has hidden face removal....

:*)
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22