1K BASIC demo

Started by Devilmarkus, 14:04, 05 December 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

Here's a 1k BASIC demo I wrote today:
10 RANDOMIZE 2011:MODE 0:FOR t=0 TO 15:INK t,0:NEXT:INK 1,26:INK 2,9:INK 3,18
20 k=20:FOR x=0 TO 640 STEP 4:p=RND*2:PLOT x,0,2:DRAW x,20+k+p:PLOT x,20+p+k,1:DRAW x,22+p+k:IF x>300 AND x<600 THEN k=k+0.25 ELSE IF x<150 THEN k=k-0.5
30 pf=INT(RND*2011):IF pf>500 THEN GOTO 60 ELSE IF pe<4 THEN pe=4
40 g=INT(RND*8)+1:FOR y=400 TO 22+p+k STEP -g:PLOT x+RND*16,y,pe:y=y-RND*8:pe=pe+1:IF pe > 15 THEN pe=4
50 NEXT y
60 FOR l=0 TO RND*4:PLOT x,RND*(18+p+k),(RND*1)+2:NEXT:NEXT
70 a=4+s:FOR t=4 TO 15:IF t=a THEN INK t,26 ELSE INK t,0
80 NEXT:CALL &BD19:s=s+1:IF s>11 THEN s=0
90 GOTO 70


Have Fun!
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Johnny Olsen

nicely, but we already have enough of it here in Denmark   :)

Gryzor

Amstrad Action time of the year! :)

Devilmarkus

Quote from: Johnny Olsen on 15:53, 05 December 10
nicely, but we already have enough of it here in Denmark   :)

Yeah, we, too :D
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

AMSDOS

Devilmarkus wrote:

Here's a 1k BASIC demo I wrote today:

10 RANDOMIZE 2011:MODE 0:FOR t=0 TO 15:INK t,0:NEXT:INK 1,26:INK 2,9:INK 3,18
20 k=20:FOR x=0 TO 640 STEP 4:p=RND*2:PLOT x,0,2:DRAW x,20+k+p:PLOT x,20+p+k,1:DRAW x,22+p+k:IF x>300 AND x<600 THEN k=k+0.25 ELSE IF x<150 THEN k=k-0.5
30 pf=INT(RND*2011):IF pf>500 THEN GOTO 60 ELSE IF pe<4 THEN pe=4
40 g=INT(RND*+1:FOR y=400 TO 22+p+k STEP -g:PLOT x+RND*16,y,pe:y=y-RND*8:pe=pe+1:IF pe > 15 THEN pe=4
50 NEXT y
60 FOR l=0 TO RND*4:PLOT x,RND*(18+p+k),(RND*1)+2:NEXT:NEXT
70 a=4+s:FOR t=4 TO 15:IF t=a THEN INK t,26 ELSE INK t,0
80 NEXT:CALL &BD19:s=s+1:IF s>11 THEN s=0
90 GOTO 70


Have Fun!

And you want me to do that in Turbo Pascal? I don't think it'll let me RANDOMIZE 2011!  ???  You deliberately put in those GOTOs just to annoy me didn't you?  ;)

* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Devilmarkus

Quote from: CP/M User on 10:04, 06 December 10
And you want me to do that in Turbo Pascal? I don't think it'll let me RANDOMIZE 2011!  ???  You deliberately put in those GOTOs just to annoy me didn't you?  ;)

Sure...  :P
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

redbox

Ah cr*p, your snow routine is better than mine and you did it in 1k of BASIC.  ;D

Devilmarkus

Well maybe because I use colour cycling instead of plotting the snow pixels each frame ;)

Here's V2! (Still 1k but nicier)
10 RANDOMIZE 2011:MODE 0:FOR t=0 TO 15:INK t,0:NEXT:INK 1,26:INK 2,9:INK 3,18
20 k=20:FOR x=0 TO 640 STEP 4:p=RND*2:PLOT x,0,2:DRAW x,20+k+p:PLOT x,20+p+k,1:DRAW x,22+p+k:IF x>300 AND x<600 THEN k=k+0.25 ELSE IF x<150 THEN k=k-0.5
30 pf=INT(RND*2011):IF pf>500 THEN GOTO 60 ELSE IF pe<4 THEN pe=4
40 g=INT(RND*8)+2:FOR y=400 TO 22+p+k STEP -g:PLOT x+RND*16,y,pe:y=y-RND*8:pe=pe+1:IF pe > 15 THEN pe=4
50 NEXT y
60 FOR l=0 TO RND*4:PLOT x,RND*(18+p+k),(RND*1)+2:NEXT:NEXT
70 u=8
80 a=4+s:b=4+u:FOR t=4 TO 15:IF t=a THEN INK t,26 ELSE IF t=b THEN INK t,13 ELSE INK t,0
90 NEXT:CALL &BD19:s=s+1:IF s>11 THEN s=0
100 u=u+1:IF u>11 THEN u=0
110 GOTO 80

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

AMSDOS

redbox wrote:

Ah cr*p, your snow routine is better than mine and you did it in 1k of BASIC.  ;D

You should do it in PL/M it's supposed to be faster than Assembly[nb]According to this guy[/nb]!

Colour Cycling is also quite a breeze in Assembly!  ;)

* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Devilmarkus

and here's v3 *lol*

10 RANDOMIZE 2011:MODE 0:FOR t=0 TO 15:INK t,0:NEXT:INK 1,26:INK 2,9:INK 3,18:BORDER 0
20 k=20:FOR x=0 TO 640 STEP 4:p=RND*2:PLOT x,0,2:DRAW x,20+k+p:PLOT x,20+p+k,1:DRAW x,22+p+k:IF x>300 AND x<600 THEN k=k+0.25 ELSE IF x<150 THEN k=k-0.5
30 pf=INT(RND*2011):IF pf>500 THEN GOTO 60 ELSE IF pe<4 THEN pe=4
40 g=INT(RND*8)+2:FOR y=400 TO 22+p+k STEP -g:PLOT x+RND*16,y,pe:y=y-RND*8:pe=pe+1:IF pe > 15 THEN pe=4
50 NEXT y
60 FOR l=0 TO RND*4:PLOT x,RND*(18+p+k),(RND*1)+2:NEXT:NEXT
70 u=8
80 a=4+s:b=4+u:FOR t=4 TO 15:IF t=a THEN INK t,26 ELSE IF t=b THEN INK t,13 ELSE INK t,0
90 NEXT:CALL &BD19:s=s+1:IF s>11 THEN s=0
100 u=u+1:IF u>11 THEN u=0
110 n=RND*640:m=RND*50:IF TEST(n,m)>1 AND TEST(n,m)<4 THEN PLOT n,m,1
120 GOTO 80


Who now can also add some trees?
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

AMSDOS

Cute, you need some grey snowflakes on the lawn though!  :laugh:

* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

redbox

Quote from: Devilmarkus on 11:50, 06 December 10
Well maybe because I use colour cycling instead of plotting the snow pixels each frame ;)

Ah, the chink in your armour  ;)

I have a background picture that isn't damaged, but I guess that's not within the confines of BASIC 1k-ers  8)

Devilmarkus

#12
Well... 2k! And I am no perfectionist in drawing trees, but:
10 RANDOMIZE 2011:MODE 0:FOR t=0 TO 15:INK t,0:NEXT:INK 1,26:INK 2,9:INK 3,18:BORDER 0:INK 4,2:INK 5,1
20 LOCATE 1,1:PEN 15:PRINT"HAPPY 2011":FOR x=0 TO 320 STEP 4:FOR y=400 TO 384 STEP -2:IF TEST(x,y)<>0 THEN PLOT x*2,-150+(y),4:PLOT x*2+4,-150+(y),4:PLOT x*2+4,-150+(y)+2,5:PLOT x*2,-150+(y)+2,5
30 NEXT:NEXT:LOCATE 1,1:PRINT"           ":PEN 1
40 k=20:FOR x=0 TO 640 STEP 4:p=RND*2:PLOT x,0,2:DRAW x,20+k+p:PLOT x,20+p+k,1:DRAW x,22+p+k:IF x>300 AND x<600 THEN k=k+0.25 ELSE IF x<150 THEN k=k-0.5
50 pf=INT(RND*2011):IF pf>1102 THEN GOTO 90 ELSE IF pe<6 THEN pe=6
60 g=INT(RND*8)+1:FOR y=400 TO 22+p+k STEP -g:l=x+RND*16:IF TEST(l,y)=0 THEN PLOT l,y,pe
70 y=y-RND*8:pe=pe+1:IF pe > 15 THEN pe=6
80 NEXT y
90 FOR l=0 TO RND*4:PLOT x,RND*(18+p+k),(RND*1)+2:NEXT:NEXT
100 u=8:GOSUB 170
110 a=6+s:b=6+u:FOR t=6 TO 15:IF t=a THEN INK t,26 ELSE IF t=b THEN INK t,13 ELSE INK t,0
120 NEXT:CALL &BD19:s=s+1:IF s>9 THEN s=0
130 u=u+1:IF u>9 THEN u=0
140 n=RND*640:m=RND*90:IF TEST(n,m)>1 AND TEST(n,m)<4 THEN PLOT n,m,1
150 v=v+1:IF v=10 THEN GOSUB 270:v=0
160 GOTO 110
170 WHILE (xx < 640)
180 h=RND*70+20:w=RND*30+20
190 g=RND*10+10:FOR y=g TO g+h STEP 2
200 FOR x=1 TO w STEP 4
210 a=INT(RND*3):IF a=0 THEN PLOT xx+x,y,2 ELSE IF a=1 THEN PLOT xx+x,y,3 ELSE PLOT xx+x,y,0
220 IF a=2 THEN PLOT xx-x,y,2 ELSE IF a=3 THEN PLOT xx-x,y,3 ELSE PLOT xx-x,y,0
230 w=w-RND*0.5:NEXT:NEXT
240 xx=xx+RND*100+20
250 WEND
260 RETURN
270 q=INT(RND*4)
280 IF q=0 THEN INK 4,2:INK 5,1
290 IF q=1 THEN INK 4,6:INK 5,3
300 IF q=2 THEN INK 4,18:INK 5,9
310 IF q=3 THEN INK 4,24:INK 5,12
320 IF q=4 THEN INK 4,17:INK 5,4
330 RETURN
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

The snow is really nice, and the trees look beautiful too - but they should get slowly covered with snow!

Also, why does it take so long to draw the landscape at the beginning? I'm going through the code but can't find what calculation is taking up so much time...?

Bryce

Because it's trees and landscape of course! Mountains take thousands of centuries to form, and trees need years before they are fully developed! Water on the other hand can freeze to snow within seconds. I didn't think I'd have to explain these things to you Gryzor! It's obvious!

Bryce.

arnoldemu

Quote from: Bryce on 11:34, 07 December 10
Because it's trees and landscape of course! Mountains take thousands of centuries to form, and trees need years before they are fully developed! Water on the other hand can freeze to snow within seconds. I didn't think I'd have to explain these things to you Gryzor! It's obvious!

Bryce.
Did anyone wait for it to run? I am sure the snow would turn into a glacier, and then you would see it slowly carve a big valley, then it would melt and reveal a beautiful mountain environment with happy rabbits and lots of grass and clear air...
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Gryzor

Yes, but it's also obvious that NATURE does not have a Z80 in it.

Speaking of which. Yesterday I was paying a visit to a big retailer and I found aNES clone in PSOne form; nothing special, maybe a dozen games for 16 euros, but the funny thing was how it proclaimed that it had a blistering fast processor at 88MHz!!!!

Gryzor

Quote from: arnoldemu on 11:46, 07 December 10
Did anyone wait for it to run? I am sure the snow would turn into a glacier, and then you would see it slowly carve a big valley, then it would melt and reveal a beautiful mountain environment with happy rabbits and lots of grass and clear air...


And the occasional frozen body of a prehistoric hunter, eh?

Devilmarkus

 :D Yes, Bryce, of course!

No, the answer is quite simple:
Because BASIC is slooooow...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Powered by SMFPacks Menu Editor Mod