Here's a game in 149 lines written some time ago for Blitz Coder:
Const SCREEN_WIDTH=800,SCREEN_HEIGHT=600,BRAIN_HUMAN=2,BRAIN_CPU=1,MAX_SPEED#=2.5,ACCELERATION#=0.03,STEER#=9,BULLET_SPEED#=2.5,ENEMY_COUNT=20,LAUNCHTIME=200
Graphics(SCREEN_WIDTH,SCREEN_HEIGHT)
SetBuffer(BackBuffer()) ; /---------- CENTAURI 149 -----------\
SeedRnd(MilliSecs()) ; | (C)2003 FOPPYGAMES |
Global g_gfx_title=LoadImage("Graphics\title.png"),g_gfx_arena=LoadImage("Graphics\toplayer.png"),g_gfx_collisionmap=LoadImage("Graphics\blueprint.png"),g_gfx_egg=LoadImage("Graphics\egg.png"),g_gfx_rocket=LoadImage("Graphics\rocket.png"),g_gfx_ship=LoadAnimImage("Graphics\rotatedship.png",16,16,0,361),g_timer=CreateTimer(60),g_player.FLYER,g_snd_shoot=LoadSound("Sounds\shoot.wav"),g_snd_boom=LoadSound("Sounds\deactivate.wav"),g_snd_explosion=LoadSound("Sounds\explosion.wav"),g_snd_playerBoom=LoadSound("Sounds\playerBoom.wav"),g_score#,g_hiScore
LoopSound(g_snd_explosion) ; | |
Type FLYER
Field f_owner,f_launching,f_x#,f_y#,f_angle#,f_speed# ; |
End Type ; | |
Function FLYER_create.FLYER(p_owner,p_x#,p_y#)
flyer.FLYER = New FLYER ; | |
flyer\f_launching = LAUNCHTIME ; | how to score points: |
flyer\f_owner = p_owner ; | - fly at higher speeds |
flyer\f_x = p_x ; | - shoot enemies (10 pts each) |
flyer\f_y = p_y ; | (note: each shot costs 1 point) |
Return(flyer) ; \-----------------------------------/
End Function
Function FLYER_controlCPU(p_flyer.FLYER)
targetAngle = ATan2(g_player\f_y+Rand(-10,10)-p_flyer\f_y,g_player\f_x+Rand(-10,10)-p_flyer\f_x)
If (targetAngle < 0) Then targetAngle = targetAngle + 360
normal = targetAngle - p_flyer\f_angle
If (normal < 0) Then normal = normal + 360
If ((normal < 358) And (normal > 180)) Then p_flyer\f_angle = p_flyer\f_angle - STEER/(p_flyer\f_speed+2.0)
If ((normal > 2) And (normal <= 180)) Then p_flyer\f_angle = p_flyer\f_angle + STEER/(p_flyer\f_speed+2.0)
p_flyer\f_angle = p_flyer\f_angle Mod 360 + (p_flyer\f_angle<0)*360
If ((normal > 350) Or (normal < 10)) Then
If (p_flyer\f_speed < MAX_SPEED) Then p_flyer\f_speed = p_flyer\f_speed + ACCELERATION
If (Rand(1000)>998) Then BULLET_create(p_flyer)
Else
p_flyer\f_speed = p_flyer\f_speed * 0.98
End If
End Function
Function FLYER_controlHuman(p_flyer.FLYER)
If (KeyDown(203)) Then steering# = -STEER/(p_flyer\f_speed+2.0)
If (KeyDown(205)) Then steering# = STEER/(p_flyer\f_speed+2.0)
p_flyer\f_angle = p_flyer\f_angle + steering
p_flyer\f_angle = p_flyer\f_angle Mod 360 + (p_flyer\f_angle<0)*360
If ((KeyDown(200)) And (p_flyer\f_speed < MAX_SPEED)) Then p_flyer\f_speed = p_flyer\f_speed + ACCELERATION
If (KeyDown(208)) Then p_flyer\f_speed = p_flyer\f_speed * 0.98
If (KeyHit(57)) Then BULLET_create(p_flyer)
End Function
Function FLYER_recreate(p_flyer.FLYER)
p_flyer\f_launching = LAUNCHTIME
p_flyer\f_x = 10+Rand(SCREEN_WIDTH-20)
p_flyer\f_y = 10+Rand(SCREEN_HEIGHT-20)
End Function
Type BULLET
Field f_owner,f_x,f_y,f_angle#
End Type
Function BULLET_create(p_owner.FLYER)
bullet.BULLET = New BULLET
bullet\f_x = p_owner\f_x + 7
bullet\f_y = p_owner\f_y + 7
bullet\f_angle = p_owner\f_angle
bullet\f_owner = p_owner\f_owner
If ((p_owner\f_owner = BRAIN_HUMAN) And (g_score > 1)) Then g_score = g_score - 1
PlaySound(g_snd_shoot)
End Function
Repeat
FlushKeys()
DrawBlock(g_gfx_arena,0,0)
DrawImage(g_gfx_title,SCREEN_WIDTH/2-239,SCREEN_HEIGHT/3-136)
Text(230,500,"hi-score: "+Str(g_hiScore))
Flip
Repeat
If KeyHit(57) Then Exit
If KeyHit(1) Then End
Forever
g_player.FLYER=FLYER_create(BRAIN_HUMAN,215,224)
For i = 1 To ENEMY_COUNT
FLYER_create(BRAIN_CPU,10+Rand(SCREEN_WIDTH-20),10+Rand(SCREEN_HEIGHT-20))
Next
FlushKeys()
continue = True
explosionChannel = PlaySound(g_snd_explosion)
g_score = 0
Color(255,255,255)
While(((Not(KeyHit(1))) And (continue)))
For flyer.FLYER = Each FLYER
flyer\f_launching = flyer\f_launching + (flyer\f_launching=0) - 1
If (flyer\f_launching = 0) Then
If (flyer\f_owner = BRAIN_CPU) Then
FLYER_controlCPU(flyer)
Else
FLYER_controlHuman(flyer)
End If
flyer\f_x = flyer\f_x + Cos(flyer\f_angle)*flyer\f_speed
flyer\f_y = flyer\f_y + Sin(flyer\f_angle)*flyer\f_speed
If (ImagesCollide(g_gfx_ship,flyer\f_x,flyer\f_y,flyer\f_angle,g_gfx_collisionmap,0,0,0)) Then
If (flyer\f_owner = BRAIN_CPU) Then
FLYER_recreate(flyer)
Else
continue = False
End If
Else If (flyer\f_owner = BRAIN_CPU) Then
If (ImagesCollide(g_gfx_ship,flyer\f_x,flyer\f_y,flyer\f_angle,g_gfx_ship,g_player\f_x,g_player\f_y,g_player\f_angle)) Then continue = False
End If
Else If (ImagesCollide(g_gfx_egg,flyer\f_x,flyer\f_y,0,g_gfx_collisionmap,0,0,0)) Then
FLYER_recreate(flyer)
End If
Next
For bullet.BULLET = Each BULLET
bullet\f_x = bullet\f_x + Cos(bullet\f_angle)*BULLET_SPEED*bullet\f_owner
bullet\f_y = bullet\f_y + Sin(bullet\f_angle)*BULLET_SPEED*bullet\f_owner
If (ImagesCollide(g_gfx_rocket,bullet\f_x,bullet\f_y,0,g_gfx_collisionmap,0,0,0)) Then
Delete(bullet)
Else
For flyer.FLYER = Each FLYER
If (ImagesCollide(g_gfx_rocket,bullet\f_x,bullet\f_y,0,g_gfx_ship,flyer\f_x,flyer\f_y,flyer\f_angle)) Then
If (flyer\f_owner <> bullet\f_owner) Then
PlaySound(g_snd_boom)
Delete(bullet)
If (flyer\f_owner = BRAIN_CPU) Then
FLYER_recreate(flyer)
g_score = g_score + 10
Else
continue = False
End If
Exit
End If
End If
Next
End If
Next
WaitTimer(g_timer)
DrawBlock(g_gfx_arena,0,0)
For flyer.FLYER = Each FLYER
If (Not(flyer\f_launching)) Then
DrawImage(g_gfx_ship,flyer\f_x,flyer\f_y,flyer\f_angle)
Else If (flyer\f_launching < LAUNCHTIME-1)
random = (LAUNCHTIME - flyer\f_launching) / 100
DrawImage(g_gfx_egg,flyer\f_x+Rand(-random,random),flyer\f_y+Rand(-random,random))
End If
Next
For bullet.BULLET = Each BULLET
DrawBlock(g_gfx_rocket,bullet\f_x,bullet\f_y)
Next
g_score = g_score + (g_player\f_speed)/100.0
Text(10,10,Str(Int(g_score)))
Flip
Wend
PlaySound(g_snd_playerBoom)
StopChannel(explosionChannel)
If (g_score > g_hiScore) Then g_hiScore = g_score
Delay(1000)
Delete Each FLYER
Delete Each BULLET
Forever
End
In fact you can put more commands on a single line but there were some rules.
I also have the following "colorful snake effect" (this requires no media):
; colorful snake effect...
Const SCREEN_WIDTH = 640
Const SCREEN_HEIGHT = 480
Const SCREEN_WIDTH_HALF = SCREEN_WIDTH / 2
Const SCREEN_HEIGHT_HALF = SCREEN_HEIGHT / 2
Graphics(SCREEN_WIDTH,SCREEN_HEIGHT,32,1)
SetBuffer(BackBuffer())
SeedRnd(MilliSecs())
Global lastColor = 512 - 1
; create a palette of 512 colors
Dim g_colors(lastColor,2)
index = 0
For red = 0 To 7
For green = 0 To 7
For blue = 0 To 7
g_colors(index,0) = Floor(red * (8.0/7.0) * 31.875)
g_colors(index,1) = Floor(green * (8.0/7.0) * 31.875)
g_colors(index,2) = Floor(blue * (8.0/7.0) * 31.875)
index = index + 1
Next
Next
Next
; do the snake effect
break = False
While (Not(KeyHit(1)))
For c = 0 To 360 Step 6
Cls
For index = 0 To lastColor
Color(g_colors(index,0),g_colors(index,1),g_colors(index,2))
Line(SCREEN_WIDTH_HALF-lastColor/2+index-Int(Cos(c)*6*Rnd(-4,4)),SCREEN_HEIGHT_HALF+Sin(index+c)*20-Int(Sin(c)*6*Rnd(0,1)),SCREEN_WIDTH_HALF-lastColor/2+index+Int(Cos(c)*6*Rnd(-4,4)),SCREEN_HEIGHT_HALF+Sin(index+c)*10+Int(Sin(c)*6*Rnd(0,1)))
Next
Flip
Next
Wend
End
The evil part is the Line command, I think I just kept adding things at random until I got an effect. (And the magical number 31.875 is also interesting.)