Breakout 2000 / Arkanoid with WAVES
Monkey Forums/Monkey Code/Breakout 2000 / Arkanoid with WAVES
| ||
It was suggested that I put the code here so... Try it out in HTML5 This one has an actual graphic image for the lava. ![]() Strict Import mojo Class MyApp Extends App Field mx:Int , my:Int Field wave:Int[640] Field ballx:Float Field bally:Float Field ballspeedx:Float Field ballspeedy:Float Field balldirx:Int Field balldiry:Int Field fireball:Int Field timer:Int Field toggle:Int = 1 Field freq:float Field ht:Int Field st:Float Field volume:Int Field speed:Int Method OnCreate:Int() st = 0 ht = 32 freq = 0.1 volume = 445 speed = 2 ballx = 100 bally = 100 balldirx = 1 balldiry = 1 ballspeedx = 2 ballspeedy = 2 fireball = 0 timer = 0 For Local i:Int = 0 To 639 wave[i] = volume Next SetUpdateRate(60) Return(0) End Method OnUpdate:Int() If fireball timer = timer -1 If timer = 0 fireball = 0 End if End If ballx += ((ballspeedx+fireball)*balldirx) bally += ((ballspeedy+fireball)*balldiry) If ballx >= 638 ballx = 638 balldirx = -1 End If If ballx <= 1 ballx = 1 balldirx = 1 End If If bally >= wave[ballx] bally = wave[ballx]-2 fireball += 2 If fireball > 6 fireball = 6 End if timer = 180 balldiry = -1 End If If balldiry > 0 If bally >= wave[mx]-32 And bally <= wave[mx]-24 And ballx > mx - 32 And ballx < mx + 32 balldiry = -balldiry If ballx > mx - 32 And ballx < mx - 24 Then ballspeedx = 4 If ballx >= mx - 24 And ballx < mx - 16 Then ballspeedx = 3 If ballx >= mx - 16 And ballx < mx - 8 Then ballspeedx = 2 If ballx >= mx - 8 And ballx <= mx + 8 Then ballspeedx = 1 If ballx >= mx + 24 And ballx < mx + 32 Then ballspeedx = 4 If ballx >= mx + 16 And ballx < mx + 24 Then ballspeedx = 3 If ballx >= mx + 8 And ballx < mx + 16 Then ballspeedx = 2 End If End If If bally <= 0 Then balldiry = 1 mx = MouseX() If KeyHit(KEY_UP) Then ht += 1 If KeyHit(KEY_DOWN) Then ht -= 1 If KeyHit(KEY_LEFT) Then freq -= .1 If KeyHit(KEY_RIGHT) Then freq += .1 If KeyHit(KEY_MINUS) Then volume += 1 If KeyHit(KEY_EQUALS) Then volume -= 1 If KeyHit(KEY_Q) Then speed -= 1 If KeyHit(KEY_W) Then speed += 1 If KeyHit(KEY_SPACE) Then toggle = 1 - toggle If KeyHit(KEY_1) st = 0 ht = 32 freq = 0.1 volume = 445 speed = 2 End If If KeyHit(KEY_2) st = 0 ht = 115 freq = .09 volume = 300 speed = 7 End If If KeyHit(KEY_3) st = 0 ht = 73 freq = .09 volume = 405 speed = 2 End If If KeyHit(KEY_4) st = 0 ht = 60 freq = .4 volume = 417 speed = 3 End If If KeyHit(KEY_5) st = 0 ht = 44 freq = 0.3 volume = 375 speed = 3 End If If KeyHit(KEY_6) st = 0 ht = 1 freq = 0 volume = 469 speed = 1 End If If speed = 0 Then speed = 1 For Local j:Int = 1 To speed st = st + freq wave[639] = Sin(st)*ht + volume For Local i:Int = 0 To 638 wave[i] = wave[i+1] Next Next Return(0) End Method OnRender:Int() Cls(0,0,0) SetColor(127+Rnd(64),0,0) For Local i:Int = 0 To 639 DrawLine(i,wave[i],i,480) next SetColor(127,127,127) DrawLine(0,volume,639,volume) DrawRect(635,Sin(90)*ht + volume - 2,4,4) DrawRect(635,Sin(-90)*ht + volume - 2,4,4) SetColor(255,255,255) If toggle DrawText("Mouse X: "+mx,0,0) DrawText("Wave Height: "+ht,0,13) DrawText("Wave Frequency: "+freq,0,26) DrawText("Liquid Volume: "+volume,0,39) DrawText("Wave Speed: "+speed,0,51) DrawText("Presets Press 1 - 6",300,0) DrawText("Space Bar to toggle text",300,13) DrawText("Press UP / DOWN to Increase / Decrease wave height",0,78) DrawText("Press LEFT / RIGHT to Decrease / Increase wave frequency",0,91) DrawText("Press - / + to Lower / Raise the liquid volume",0,104) DrawText("Wave Speed Q / W to Decrease / Increase speed",0,117) DrawText("Ball X Speed: "+ballspeedx,300,26) DrawText("Ball Y Speed: "+ballspeedy,300,39) End if SetColor(127,127,127) DrawRect(mx-32,wave[mx]-32,8,16) DrawRect(mx+24,wave[mx]-32,8,16) SetColor(159,159,159) DrawRect(mx-24,wave[mx]-32,8,16) DrawRect(mx+16,wave[mx]-32,8,16) SetColor(191,191,191) DrawRect(mx-16,wave[mx]-32,8,16) DrawRect(mx+8,wave[mx]-32,8,16) SetColor(255,255,255) DrawRect(mx-8,wave[mx]-32,16,16) If fireball SetColor(255,0,0) Else SetColor(127,127,255) End If DrawRect(ballx-2,bally-2,4,4) Return(0) End End Class Function Main:Int() New MyApp Return(0) End Function If you do anything cool with it please share. |