Breakout 2000 or Arkanoid with WAVES

Monkey Forums/Monkey Programming/Breakout 2000 or Arkanoid with WAVES

Loofadawg(Posted 2013) [#1]
Because of Paul - "Taiphoz"'s Power Up Discussion for his Hexanoid type game I was inspired to hack together some code for an idea I had. Originally written in Blitz Basic many moons ago I have resurrected some of it in Monkey.

There are no graphics to import or anything just copy / paste / execute.


Admittedly the waves are more of a gimmick but I wanted to test it to see if I could breath new life into the genre.

Ideas not implemented are capsules that rise the lava level, temporary freeze the lava, make the the lava nearly flat and calm etc..

Other ideas would be you are at the bottom of a volcano shaft and you have to bust your way up through all the time the lava is slowly rising and as it rises so do you. If you hit the ceiling - instant death.

As you rise through the shaft more bricks / obstacles appear.
Kind of and endless runner game but in breakout form. Shafts could branch out depending which shaft you break through first.

Plus maybe the paddle could tilt based on the lava beneath it.

That code is ugly / buggy but and not terribly complicated to implement but may inspire someone.

If anybody feels like rewriting <grin> and adding features I would love to see it. Could be a community project even (???)

Most of all, tell me what you think of the concept of a moving liquid floor.

Initially I was going for the whole Temptest 2000 / Llamatron treatment.

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



Paul - Taiphoz(Posted 2013) [#2]
yeah it was a really good suggestion and it gave me a load of ideas, which I now have in motion.

really good seeing an example of it, you should throw that into the code section as well I am sure it would be handy for some one at some stage in the future.


Loofadawg(Posted 2013) [#3]
That's cool. I can't wait to play / buy the finished product.

I copied the code to the other forum, I guess that would have been a better place for it. ;)


Why0Why(Posted 2013) [#4]
Pretty cool and those are some good ideas for a game.


slenkar(Posted 2013) [#5]
aye its really good laddie


zoqfotpik(Posted 2014) [#6]
I had thought of doing something like this with a dynamic sand dune floor that would be built up somehow over time, maybe by falling fragments that you missed catching.