The 50 years ago moon landing 4K contest!
Re: The 50 years ago moon landing 4K contest!
@UEZ
Moonshine 700 bytes -> Simply beautiful
Best regards
Moonshine 700 bytes -> Simply beautiful
Best regards
Re: The 50 years ago moon landing 4K contest!
Here's my entry…
The moon landing from Collins' perspective
there's still room for improvements…
Use arrow Keys to move the module, spacebar to throttle.
Even horizontal movement uses fuel. Don't waste the fuel.
I didn't realize that my coding style wasted huge amount of bytes :)
The moon landing from Collins' perspective
there's still room for improvements…
Use arrow Keys to move the module, spacebar to throttle.
Even horizontal movement uses fuel. Don't waste the fuel.
I didn't realize that my coding style wasted huge amount of bytes :)
Code: Select all
#include "fbgfx.bi"
Using FB
randomize timer
#define df #define
df bo boolean
df Lo long
df Ul Ulong
df si single
df st string
df mk multikey
df c0 &hFFFFFF
df c1 &hCCCCCC
df c2 &hBBBBBB
df cl circle
df ln line
df fn function
df ty type
fn _abtp(a as si,b as si,c as si,d as si)as si
return -Atan2(d-b,c-a)
end fn
fn dist(a as si,b as si,c as si,d as si)as si
return Sqr(((a-c)*(a-c))+((b-d)*(b-d)))
end fn
DIM wp AS Ul
dim as Ul i,j
dim grv as si=2.5
dim inr as si=0.99
ty hl_p
x as Ul
y as Ul
d as Ul
end ty
ty e_p
x as si
y as si
z as si
th_power as si
vs as si
old_z as si
dirctn as si
ai as bo
th as bo
x_dir as si
y_dir as si
z_power as si
hp as si
f as si
pts as Ul
l as Ul
s as Lo
end ty
dim shared e as e_p
dim shared trg as hl_p
sub rst_trg
trg.x=rnd*440+100
trg.y=rnd*380+50
trg.d=50
end sub
rst_trg
sub rst_e
e.x=rnd*400+50
e.y=rnd*200+50
e.z=1200
e.f=100
e.ai=false
e.s=0
end sub
rst_e
dim hl(0 to 255)as hl_p
for i=0 to Ubound(hl)
hl(i).x=rnd*640
hl(i).y=rnd*480
hl(i).d=rnd*30
next i
wp=0
dim msg as string
dim hs as Ulong=0
screenres(640,480,24,2)
do
if mk(FB.SC_ESCAPE)then exit do
e.old_z=e.z
e.z-=grv
e.z_power*=inr
e.ai=false
e.x_dir=0
e.y_dir=0
e.th=false
if mk(FB.SC_LEFT)then
e.x_dir=-1
e.ai=true
end if
if mk(FB.SC_RIGHT)then
e.x_dir=1
e.ai=true
end if
if mk(FB.SC_UP)then
e.y_dir=-1
e.ai=true
end if
if mk(FB.SC_DOWN)then
e.y_dir=1
e.ai=true
end if
if mk(FB.SC_SPACE)then
e.th=true
end if
if e.ai then
e.dirctn=_abtp(0 ,0,e.x_dir,e.y_dir)
e.hp=1.15*e.z/1000
else
e.hp*=inr
end if
if e.th and e.f>0 then
e.th_power+= 0.15
if e.th_power>3.5 then
e.th_power=3.5
end if
e.f-=0.1
else
e.th_power*=0.95
end if
if e.ai then
e.f-=0.1
end if
e.z+= e.th_power
e.x+= cos(e.dirctn)*e.hp
e.y+= -sin(e.dirctn)*e.hp
e.vs=e.old_z-e.z
if(e.z <=0)and(e.vs<1)then
if dist(e.x+e.z/4,e.y+e.z/4,trg.x,trg.y)< trg.d then
e.pts+= 50-int(dist(e.x+e.z/4,e.y+e.z/4,trg.x,trg.y))*(e.l +1)
if e.pts>hs then hs=e.pts
e.s=1
else
e.s=-2
end if
elseif(e.z <=0)and(e.vs >= 1)then
e.s=-1
end if
screenset wp,1-wp
screenlock
cls
ln(0,0)-step(640,480),c1,BF
for i=0 to Ubound(hl)
cl(hl(i).x+3,hl(i).y+3),hl(i).d,&h999999,,,,F
cl(hl(i).x-3,hl(i).y -3),hl(i).d,&hBBBBBB,,,,F
cl(hl(i).x,hl(i).y),hl(i).d,&hCCCCCC,,,,F
next i
if dist(e.x+e.z/4,e.y+e.z/4,trg.x,trg.y)< trg.d then
cl(trg.x,trg.y),trg.d,&h00FF00
else
cl(trg.x,trg.y),trg.d,&hFF0000
end if
ln(e.x+e.z/4,e.y+e.z/4)-step(4,4),&hAAAAAA ,BF
if e.th and e.f>0 then
cl(e.x+(e.z/20+4)/2,e.y+(e.z/20+4)/2),e.z/30+4+rnd*5,&hFF0000,,,,F
end if
cl(e.x,e.y),e.z/80+4,c2,,,,F
cl(e.x+e.z/20+4,e.y),e.z/80+4,c2,,,,F
cl(e.x+e.z/20+4,e.y+e.z/20+4),e.z/80+4,c2,,,,F
cl(e.x,e.y+e.z/20+4),e.z/80+4,c2,,,,F
ln(e.x,e.y)-step(e.z/20+4,e.z/20+4),&hEEEEEE ,BF
ln(e.x,e.y)-step(e.z/20+4,e.z/20+4),c0 ,B
cl(e.x+(e.z/20+4)/2,e.y+(e.z/20+4)/2),e.z/60+4,c0,,,,F
ln(620,0)-(640,480),&h0,BF
if(e.vs<1)then
ln(620,470-e.z)-step(20,10),&h00FF00,BF
else
ln(620,470-e.z)-step(20,10),&hFF0000,BF
end if
draw string(20,50),"V SPD: "+str(e.vs)
if e.f<0 then
draw string(20,40),"NO FUEL",&hFF0000
else
draw string(20,40),"FUEL:"+str(e.f)
end if
draw string(20,400),"PTS: "+str(e.pts)
draw string(500,20),"HIGHSCORE: "+str(hs)
ln(0,460)-step(620,20),0,BF
draw string(20,465),msg
if e.s=1 then
msg="THE EAGLE HAS LANDED!"
rst_e
e.l+=1
e.f=100-e.l *3
trg.x=rnd*440+100
trg.y=rnd*380+50
trg.d=50/(e.l*1.1)
elseif e.s=-1 then
msg="OPS!"
rst_e
e.l=0
e.pts=0
rst_trg
elseif e.s=-2 then
msg="OUT OF TARGET!!!"
rst_e
e.l=0
e.pts=0
rst_trg
end if
screenunlock
sleep 20,1
wp=1-wp
loop
sleep
Last edited by Pitto on Aug 07, 2019 12:04, edited 1 time in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: The 50 years ago moon landing 4K contest!
@Pitto good job
Nice and tiny :-)
Joshy
Nice and tiny :-)
Joshy
Re: The 50 years ago moon landing 4K contest!
Thank you.
I think I can squeeze other bytes and add some feature.
It's a funny contest.
I think I can squeeze other bytes and add some feature.
It's a funny contest.
Re: The 50 years ago moon landing 4K contest!
sleep 20,1 needs to be outside screenlock / screenunlock for your code to work properly on my (linux) system.Pitto wrote:Here's my entry…
The moon landing from Collins' perspective
...
But horizontal movement is still possible without fuel :-)Pitto wrote: Even horizontal movement uses fuel. Don't waste the fuel.
The contest happened during my camping trip. Luckily there is no deadline, so I'll try to make something this week. A bit worried about the 4K limit.
Re: The 50 years ago moon landing 4K contest!
Much as I like UEZ's and Pitto's contributions, I don't think contestants should shower praise on each other.
Rather, they should root out bugs in each other's code.
But D.J.Peters is the boss of this thread, so he has the say.
Hope you managed to avoid pneumonia badidea.
Rather, they should root out bugs in each other's code.
But D.J.Peters is the boss of this thread, so he has the say.
Hope you managed to avoid pneumonia badidea.
Re: The 50 years ago moon landing 4K contest!
Code: Select all
? "-Houston, we have a problem..."
sleep 1000
? "-What's the problem?"
sleep 1000
? "-Some issues on Linux here"
sleep 1000
? "-Swap line 202 with 203 and recompile... next time please read better the manual"
? " see https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgScreenlock"
sleep 2000
? "-Ooops! Thanks a lot!"
? " Fixed!"
sleep
-
- Posts: 165
- Joined: Apr 19, 2019 19:03
Re: The 50 years ago moon landing 4K contest!
BTW, if they would have used linux they not only came to moon but directly to mars...
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: The 50 years ago moon landing 4K contest!
Same here 'stupid rule' ;-)badidea wrote:A bit worried about the 4K limit.
after I got my polygon filler down under 1 K
it's hard for me to get the sound output for Windows and Linux, (yes I'm positive crazy but I name it "creative")
the 3d stuff and the game code it self in the rest of the 3K !
I know there isn't sound in vacuum space but hey it's fun.
I'm working on it, not often but from time to time !
Two times I deleted all and began from zero again.
here are: "1st place in PC 4k compo at Breakpoint 2009"
youtube: https://www.youtube.com/watch?v=jB0vBmiTr6o
here are the slides how it was made in 4K
pdf: http://www.iquilezles.org/www/material/ ... on2009.pdf
Joshy
Re: The 50 years ago moon landing 4K contest!
I was thinking about making some simulation of the Apollo missions from Earth launch to re-entry. But it was a pretty complex procedure:
https://en.wikipedia.org/wiki/Apollo_pr ... on_profile
Two rocket stages are discarded within 11 minutes, a 3rd stage a bit later when traveling closer to the moon. One part (CSM) with 1 person stayed in moon orbit while 2 other persons landed on moon with the lunar module (LM). LM goes back to CSM, leaving stuff behind on the moon. Then fly back to Earth leaving the LM to crash back of the moon. Then before Earth re-entry leaving more stuff behind, the 3 persons drop to Earth in a very tiny thing compared to whole machine launched initially. There is a 14-story high building near my house which is, I think, pretty big. The complete Saturn V is 2.5 times as high. Pretty crazy, who would volunteer to sit in the top of this fuel filled thing?
https://en.wikipedia.org/wiki/Apollo_pr ... on_profile
Two rocket stages are discarded within 11 minutes, a 3rd stage a bit later when traveling closer to the moon. One part (CSM) with 1 person stayed in moon orbit while 2 other persons landed on moon with the lunar module (LM). LM goes back to CSM, leaving stuff behind on the moon. Then fly back to Earth leaving the LM to crash back of the moon. Then before Earth re-entry leaving more stuff behind, the 3 persons drop to Earth in a very tiny thing compared to whole machine launched initially. There is a 14-story high building near my house which is, I think, pretty big. The complete Saturn V is 2.5 times as high. Pretty crazy, who would volunteer to sit in the top of this fuel filled thing?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: The 50 years ago moon landing 4K contest!
Yes jet fighters in this day's was sitting near the turbine engines and the rockets on the wings !
They are the right persons for this crazy mission ;-)
My first idea was a "Lunar Roving Vehicle" game on the moon with low gravity (what a fun)
but it was later in 1971 Apollo 15-17, damned :-)
Joshy
They are the right persons for this crazy mission ;-)
My first idea was a "Lunar Roving Vehicle" game on the moon with low gravity (what a fun)
but it was later in 1971 Apollo 15-17, damned :-)
Joshy
-
- Posts: 556
- Joined: Mar 10, 2007 15:44
- Location: Ohio, USA
- Contact:
Re: The 50 years ago moon landing 4K contest!
A lot of brave men.badidea wrote:... who would volunteer to sit in the top of this fuel filled thing?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: The 50 years ago moon landing 4K contest!
I got Windows and Linux sound output under 1K each.
That's one small step for man, one giant leap for my mini game :-)
Here are the windows part 910 bytes I post it only for fun how the hand compressed BASIC looks.
It includes all what sample playback needs
sample buffer fill thread
device message callback
mutex and conditions
wave format definition
wave header allocation
sample buffer allocation
and many fun
...
Let me know if you will see how it looks decompressed or if you like to use it in your own next game or demo.
After I wrote the Windows MME, Directsound and dsp, arts and Alsa Linux driver for FBSound
I self never thinking I can get it in 15 lines of code,
it's fun if you surprise yourself.
Joshy
That's one small step for man, one giant leap for my mini game :-)
Here are the windows part 910 bytes I post it only for fun how the hand compressed BASIC looks.
It includes all what sample playback needs
sample buffer fill thread
device message callback
mutex and conditions
wave format definition
wave header allocation
sample buffer allocation
and many fun
...
Let me know if you will see how it looks decompressed or if you like to use it in your own next game or demo.
After I wrote the Windows MME, Directsound and dsp, arts and Alsa Linux driver for FBSound
I self never thinking I can get it in 15 lines of code,
it's fun if you surprise yourself.
Joshy
Code: Select all
ty(_s)a16 l,r:yt:ty(_h)ps s:a32 b,c:pa u:a32 f,lo:pa n,r yt ty(_m)ph h:pa w,m,c:a32 e yt
d SH sizeof(_h)
d wp (pa,pa,a32=SH) a32
d ah(x) dph x am(SH) x->s am(SS*4) x->b=SS*4:
d ah3 ah(h1) ah(h2) ah(h3)
d wo3 wop(hwo,h1):wop(hwo,h2):wop(hwo,h3):wow(hwo,h1):wow(hwo,h2):wow(hwo,h3):
df woo a(waveOutOpen)(pa,a32=-1,pa,pa,pa,a32=&h30000) a32 df woc a(waveOutClose)(pa) a32 df wor a(waveOutReset)(pa) a32 df wop a(waveOutPrepareHeader) wp df wow a(waveOutWrite) wp
#inclib "winmm"
su cb(dh pa,msg a32,m pm,h ph,p2 pa):sc msg
ca 956:it(m) m->e=1:cs m->c
ca 957:it(m->c) m->h=h:cs m->c
es us su dsp(x pa) dpm m=x:m->e=0 wh m->e=0:ml(m->m):cw(m->c,m->m):mul(m->m):it(m->e=0)
ti hw us dp32 hwo,wf am(18) wf[0]=&H20001:wf[1]=RA:wf[2]=wf[1] shl 2:wf[3]=&H100004
ah3 dpm m am(sizeof(_m)) woo(@hwo,,wf,@cb,m):m->w=hwo:m->m=mc:m->c=cc:m->e=1:tc(@dsp,m):wh m->e=1:sleep 10:hw:wo3
sleep:m->e=1:wor(hwo):woc(hwo)
Re: The 50 years ago moon landing 4K contest!
Land It - a primitiv game where you have to land the shuttle on a flat ground.
Arrow keys to steer shuttle (yellow). You must land less than 0.5 speed. Press Enter to start and Q to exit game. When "Game over" is displayed, press R to restart.
Version 0.25 (3312 bytes):
Normal version v0.25 (4987 bytes):
Arrow keys to steer shuttle (yellow). You must land less than 0.5 speed. Press Enter to start and Q to exit game. When "Game over" is displayed, press R to restart.
Version 0.25 (3312 bytes):
Code: Select all
'Coded by UEZ v0.25 build 2019-08-14
#Include "fbgfx.bi"
Using FB
#Define Df #Define
Df Mk Multikey
Df Ln Line
Df Pt Point
Df Rd Rnd
Df Nx Next
Df Tn Then
Df Sg String
Df Fr For
Df El Else
Df EI EndIf
Df Dw Draw
Df Ad And
Df Dm Dim
Df Cc Circle
Df Sl Single
Declare Sub Ex()
Randomize ,2:Dm Shared As Ubyte bX,bXX:Dm Shared As Ushort w=1000,h=600:Dm As Ushort y=h*0.8,z=y,go,gs,p,x,i,j,q=0:Dm As Sl c=0,f,speed,fuel,xx,yy,rr,aa,fps=0:Dm As Ulong cl,cr,f1=&hFF282828,f2=&hFF181818,f3=&hD0FF0000,f4=&hFFFFFF00:Screenres(w,h,32,1,GFX_NO_SWITCH Or GFX_ALPHA_PRIMITIVES)
Windowtitle "Land It v0.25 by UEZ":Dm As Sg sgo=" Game over!",rs="Press R to restart":Dm As Any Ptr Bg=Imagecreate(w,h,32):Paint Bg,(1,1),Rgba(0,0,0,255)
Fr x=0 To w:y+=Sin(-c/10)+Rd/4:c+=0.125:f=(y-1)*Rd:If f<y Tn Pset Bg,(x,f),&hFFFFFFFF:EI:Ln Bg,(x,z)-(x+1,y),f2:z=y:Nx
Cc Bg,(800,100),50,&hFF0000FF,,,,F:Paint Bg,(1,h*0.8+1),f1,f2:c=0:y=h*0.85:Const pi=Acos(-1)*2
Fr x=0 To w:y+=Sin(-c/10)+Rd/4:aa=0.1+Rd*0.8:rr=5+Rd*25:yy=y+rr+(h-y-1)*Rd:If x Mod 15=0 Tn:f=Rd*&h40:Cc Bg,(x,yy),rr,Rgba(f,f,f,&h20),,,aa,F:Cc Bg,(x,yy),rr-Rd*4,Rgba(f+8,f+8,f+8,&h60),Rd*pi,Rd*-pi,aa:EI:c+=0.125:Nx
Type vec2:As Sl x,y,vx,vy,s:End Type:Dm Shared As vec2 Ss,EP(19,9)
#Macro R()
Ss.x=Rd*w/2+w/3:Ss.y=0:Ss.s=0:Ss.vx=0:Ss.vy=1.1:speed=1:fuel=1750:go=0:gs=0:p=0:bX=0:bXX=1
Fr j=0 To 19:Fr i=0 To 9:EP(j,i).x=i:EP(j,i).y=j:EP(j,i).vx=-3+Rd*6:EP(j,i).vy=-3+Rd*6:EP(j,i).s=50+Rd*200:Nx:Nx
#Endmacro
R():Dm As Double t=Timer
Do
Screenlock:Put (0,0),Bg,Pset
If gs Tn
Ss.s=Ss.y:cl=Pt(Ss.x,Ss.y+21):cr=Pt(Ss.x+20,Ss.y+21)
If (cl<>f1) Ad (cr<>f1) Tn
Ln (Ss.x,Ss.y)-(Ss.x+10,Ss.y+20),f4,BF:Ss.x+=Ss.vx:Ss.y+=Ss.vy:Ss.vy*=1.005
If fuel>0 Tn fuel-=0.1
speed=Ss.y-Ss.s
El
If (cl<>f1) Ad (cr=f1) Or (cl=f1) Ad (cr<>f1) Tn
If p=0 Tn Dw Sg (419,200),"Collision." & sgo:Dw Sg (430,220),rs
If bXX Tn
bX=1:bXX=0:
EI:El
If speed<0.5 Tn
Ln (Ss.x,Ss.y)-(Ss.x+10,Ss.y+20),f4,BF:If p=0 Tn Dw Sg (454,200),"Well done!":Dw Sg (430,220),rs:bX=0:
El
If p=0 Tn Dw Sg (420,200),"Too fast." & sgo:Dw Sg (430,220),rs
If bXX Tn
bX=1:bXX=0
EI:EI:EI:go=1:
EI
If fuel>0 Tn
If Mk(SC_LEFT) Tn Ss.vx-=0.05:fuel-=1:Ln (Ss.x+11,Ss.y+8)-(Ss.x+16,Ss.y+12),f3,BF
If Mk(SC_RIGHT) Tn Ss.vx+=0.05:fuel-=1:Ln (Ss.x-6,Ss.y+8)-(Ss.x -1,Ss.y+12),f3,BF
If Mk(SC_Up) Tn Ss.vy-=0.05:fuel-=15:Ln (Ss.x+3,Ss.y+21)-(Ss.x+7,Ss.y+26),f3,BF
If Mk(SC_Down) Tn Ss.vy+=0.05:fuel-=5:Ln (Ss.x+3,Ss.y-6)-(Ss.x+7,Ss.y -1),f3,BF
El
Dw Sg (420,200),"Out of fuel." & sgo:Dw Sg (419,220),rs:go=1:p=1
EI
If Ss.vy<1 Tn Ss.vy+=0.005:EI:If Ss.vx<0 Tn Ss.vx+=0.001:EI:If Ss.vx>0 Tn Ss.vx-=0.001
El
If Sin(Timer*5)>0 Tn Dw Sg (354,250),"Press Enter to start landing mission!":If Mk(SC_ENTER) Tn gs=1
EI
If bX>0 Tn Ex()
Dw Sg (10,10),"Fuel: " & Str(Iif(fuel<0,0,fuel)) & " l":Dw Sg (10,20),"Speed: " & Str(speed) & " m/s":Dw Sg (10,30),"FPS: " & Str(q):Screenunlock:fps+=1
If Timer-t>0.999 Tn:t=Timer:q=fps:fps=0:EI
If Mk(SC_R) Ad go=1 Tn
R()
EI:Sleep(10,1)
Loop Until Inkey()="q"
Sub Ex()
Dm As Ushort c=0:Dm As Sl x,y:Fr j As Ubyte=0 To 19:Fr i As Ubyte=0 To 9:
EP(j,i).x+=EP(j,i).vx:EP(j,i).y+=EP(j,i).vy:EP(j,i).s-=1:x=Ss.x+EP(j,i).x:y=Ss.y+EP(j,i).y:Ln (x,y)-(x+2,y+2),Rgba(255*Rd(),0,0,255-EP(j,i).s),BF
If EP(j,i).s<0 Tn c+=1:
Nx:Nx:If c>199 Tn bX=0
End Sub
Code: Select all
'Coded by UEZ v0.25 build 2019-08-14
#Include "fbgfx.bi"
Using FB
Declare Sub Explosion()
Randomize , 2
Dim Shared As Ubyte bX, bXX
Dim Shared As Ushort w = 1000, h = 600
Dim As Ushort y = h * 0.8, z = y, go, gs, p, x, i, j, q = 0
Dim As Single c = 0, f, speed, fuel, xx, yy, rr, aa, fps = 0
Dim As Ulong cl, cr, f1 = &hFF282828, f2 = &hFF181818, f3 = &hD0FF0000, f4 = &hFFFFFF00
Screenres(w, h, 32, 1, GFX_NO_SWITCH Or GFX_ALPHA_PRIMITIVES)
Windowtitle "Land It v0.25 by UEZ"
Dim As String sgo = " Game over!", rs = "Press R to restart"
Dim As Any Ptr Bg = Imagecreate(w, h, 32)
Paint Bg, (1, 1), Rgba(0, 0, 0, 255)
For x = 0 To w
y += Sin(-c / 10) + Rnd / 4
c += 0.125
f = (y - 1) * Rnd
If f < y Then Pset Bg, (x, f), &hFFFFFFFF
Line Bg, (x, z) - (x + 1, y), f2
z = y
Next
Circle Bg, (800, 100), 50, &hFF0000FF,,,,F
Paint Bg, (1, h * 0.8 + 1), f1, f2
c = 0
y = h * 0.85
Const pi = Acos(-1) * 2
For x = 0 To w
y += Sin(-c / 10) + Rnd / 4
aa = 0.1 + Rnd * 0.8
rr = 5 + Rnd * 25
yy = y + rr + (h - y - 1) * Rnd
If x Mod 15 = 0 Then
f = Rnd * &h40
Circle Bg, (x, yy), rr, Rgba(f, f, f, &h20), , , aa, F
Circle Bg, (x, yy), rr - Rnd * 4, Rgba(f + 8, f + 8, f + 8, &h60), Rnd * pi, Rnd * -pi, aa
End If
c += 0.125
Next
Type vec2
As Single x, y, vx, vy, s
End Type
Dim Shared As vec2 Spaceship, ExplosionParticles(19, 9)
#Macro R()
Spaceship.x = Rnd * w / 2 + w / 3
Spaceship.y = 0
Spaceship.s = 0
Spaceship.vx = 0
Spaceship.vy = 1.1
speed = 1
fuel = 1750
go = 0
gs = 0
p = 0
bX = 0
bXX = 1
For j = 0 To 19
For i = 0 To 9
ExplosionParticles(j, i).x = i
ExplosionParticles(j, i).y = j
ExplosionParticles(j, i).vx = -3 + Rnd * 6
ExplosionParticles(j, i).vy = -3 + Rnd * 6
ExplosionParticles(j, i).s = 50 + Rnd * 200
Next
Next
#Endmacro
R()
Dim As Double t = Timer
Do
Screenlock
Put (0, 0), Bg, Pset
If gs Then
Spaceship.s = Spaceship.y
cl = Point(Spaceship.x, Spaceship.y + 21) : cr = Point(Spaceship.x + 20, Spaceship.y + 21)
If (cl <> f1) And (cr <> f1) Then
Line (Spaceship.x, Spaceship.y) - (Spaceship.x + 10, Spaceship.y + 20), f4, BF
Spaceship.x += Spaceship.vx
Spaceship.y += Spaceship.vy
Spaceship.vy *= 1.005
If fuel > 0 Then fuel -= 0.1
speed = Spaceship.y - Spaceship.s
Else
If (cl <> f1) And (cr = f1) Or (cl = f1) And (cr <> f1) Then
If p = 0 Then Draw String (419, 200), "Collision." & sgo : Draw String (430, 220), rs
If bXX Then
bX = 1
bXX = 0
End If
Else
If speed < 0.5 Then
Line (Spaceship.x, Spaceship.y) - (Spaceship.x + 10, Spaceship.y + 20), f4, BF
If p = 0 Then Draw String (454, 200), "Well done!" : Draw String (430, 220), rs
bX = 0
Else
If p = 0 Then Draw String (420, 200), "Too fast." & sgo : Draw String (430, 220), rs
If bXX Then
bX = 1
bXX = 0
End If
End If
End If
go = 1
End If
If fuel > 0 Then
If Multikey(SC_LEFT) Then Spaceship.vx -= 0.05 : fuel -= 1 : Line (Spaceship.x + 11, Spaceship.y + 8) - (Spaceship.x + 16, Spaceship.y + 12), f3, BF
If Multikey(SC_RIGHT) Then Spaceship.vx += 0.05 : fuel -= 1 : Line (Spaceship.x - 6, Spaceship.y + 8) - (Spaceship.x -1, Spaceship.y + 12), f3, BF
If Multikey(SC_Up) Then Spaceship.vy -= 0.05 : fuel -= 15 : Line (Spaceship.x + 3, Spaceship.y + 21) - (Spaceship.x + 7, Spaceship.y + 26), f3, BF
If Multikey(SC_Down) Then Spaceship.vy += 0.05 : fuel -= 5 : Line (Spaceship.x + 3, Spaceship.y - 6) - (Spaceship.x + 7, Spaceship.y -1), f3, BF
Else
Draw String (420, 200), "Out of fuel." & sgo : Draw String (419, 220), rs
go = 1
p = 1
End If
If Spaceship.vy < 1 Then Spaceship.vy += 0.005
If Spaceship.vx < 0 Then Spaceship.vx += 0.001
If Spaceship.vx > 0 Then Spaceship.vx -= 0.001
Else
If Sin(Timer * 5) > 0 Then Draw String (354, 250), "Press Enter to start landing mission!"
If Multikey(SC_ENTER) Then gs = 1
End If
If bX > 0 Then Explosion()
Draw String (10, 10), "Fuel: " & Str(Iif(fuel < 0, 0, fuel)) & " l"
Draw String (10, 20), "Speed: " & Str(speed) & " m/s"
Draw String (10, 30), "FPS: " & Str(q)
Screenunlock
fps += 1
If Timer - t > 0.999 Then
t = Timer : q = fps : fps = 0
End If
If Multikey(SC_R) And go = 1 Then
R()
End If
Sleep(10, 1)
Loop Until Inkey() = "q"
Sub Explosion()
Dim As Ushort c = 0
Dim As Single x, y
For j As Ubyte = 0 To 19
For i As Ubyte = 0 To 9
ExplosionParticles(j, i).x += ExplosionParticles(j, i).vx
ExplosionParticles(j, i).y += ExplosionParticles(j, i).vy
ExplosionParticles(j, i).s -= 1
x = Spaceship.x + ExplosionParticles(j, i).x
y = Spaceship.y + ExplosionParticles(j, i).y
Line (x, y)-(x + 2, y + 2), Rgba(255 * Rnd(), 0, 0, 255 - ExplosionParticles(j, i).s), BF
If ExplosionParticles(j, i).s < 0 Then c += 1
Next
Next
If c > 199 Then bX = 0
End Sub
Last edited by UEZ on Aug 15, 2019 13:02, edited 9 times in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: The 50 years ago moon landing 4K contest!
@UEZ Nice and tiny "old school" I like it.
But a little bit hard to play here !
Your main loop run's at ~100 Hz. (sleep 10,1)
if you press a key Multikey() is really fast so the keydown event are to long here.
I added a frame counter and use Multikey() at 25Hz now it's playable here.
Joshy
But a little bit hard to play here !
Your main loop run's at ~100 Hz. (sleep 10,1)
if you press a key Multikey() is really fast so the keydown event are to long here.
I added a frame counter and use Multikey() at 25Hz now it's playable here.
Joshy
Code: Select all
If (fuel>0) andalso (frames mod 4=0) Then
If Multikey(SC_LEFT) Then SS.vx-=0.1 :fuel-=1 :Line (SS.x+11,SS.y+8 )-(SS.x+16,SS.y+12),r,BF
If Multikey(SC_RIGHT) Then SS.vx+=0.1 :fuel-=1 :Line (SS.x- 6,SS.y+ 8)-(SS.x- 1,SS.y+12),r,BF
If Multikey(SC_Up) Then SS.vy-=0.05:fuel-=10:Line (SS.x+ 3,SS.y+21)-(SS.x+ 7,SS.y+26),r,BF
If Multikey(SC_Down) Then SS.vy+=0.05:fuel-=10:Line (SS.x+ 3,SS.y- 6)-(SS.x+ 7,SS.y -1),r,BF
Else
Draw String (420,200),"Out of fuel. Game Over!":go=1:p=1
End If
Last edited by D.J.Peters on Aug 13, 2019 7:40, edited 1 time in total.