Jump Around 3

Miscellaneous Forums/Blitz Showcase/Jump Around 3

Predators!
----------
I'm not good at art so I just did a quick color change[Monster03.png]:
[NoLongerInService]
Feel free to make a new cool image if desired to have this monster type. I think it's fun having something sort of chasing you! :D

I just added the code bits needed for the predator to let whoever keeping the code to update the latest source if you all want this in. If not, no biggy.

-----------
Must increase monster size to 3 from 2 like so:
Dim monsters(3)
For n=0 To 3
	monsters(n)	 = LoadAnimImage("images/Monster0"+Str(n)+".png",16,16,0,4)
Next


remmember to set 3 in monster types in the level data...

Here's the AI:
Function UpdateMonsters()

	For monster.monster=Each monster
		DrawImage monsters(monster\t),monster\x,monster\y,monster\frame
		
		If monster\dead
			monster\x = monster\x + monster\xd
			monster\y = monster\y + monster\yd
			monster\yd = monster\yd * 0.99 + 0.1
			monster\xd = monster\xd * 0.99
		Else
			monster\y=monster\y+ScrollSpeed
			monster\frame = (monster\frame + 0.1) Mod 3
	
			If monster\t < 2
				
				If monster\box<> Null
					monster\x=monster\x+monster\xd
					If monster\x+16>monster\box\x+monster\box\w
						monster\xd=-Rnd(0.1,0.5)
					ElseIf monster\x<monster\box\x
						monster\xd=Rnd(0.1,0.5)
					EndIf
				EndIf
				
			Else
				If monster\t = 2

					; Don't move until it's a bit into the screen
					If monster\y>32
						monster\x=monster\x+monster\xd
					EndIf

					If monster\box = Null
						monster\y = monster\y + monster\yd
					
						For box.box = Each box
							If RectsOverlap(monster\x+8,monster\y,1,16,box\x,box\y,box\w,box\h) = False
								If RectsOverlap(monster\x+8,monster\y+monster\yd+1,1,16,box\x,box\y,box\w,box\h)
									monster\box = box
									monster\y = box\y-16
									Exit
								EndIf							
							EndIf
						Next
						monster\yd = monster\yd * 0.99 + 0.1
					Else
						If monster\x+6>monster\box\x+monster\box\w
							monster\box = Null
							monster\yd = 0
						ElseIf monster\x+10<monster\box\x
							monster\box = Null
							monster\yd = 0
						EndIf	
					EndIf
				Else
					If monster\t = 3 ; predator AI
					
						; Don't move until it's a bit into the screen
						If monster\y>32
							monster\x=monster\x+monster\xd
							If monster\x>Player\x
								If monster\xd>-1.0 Then monster\xd=monster\xd-0.1
							Else
								If monster\xd<1.0 Then monster\xd=monster\xd+0.1
							EndIf
							If monster\box <> Null
								If monster\y>Player\y+8
									For box.box = Each box
										If RectsOverlap(monster\x+8,monster\y-1,1,16,box\x,box\y,box\w,box\h)
											monster\yd = - 3
											monster\box = Null
										EndIf
									Next
								EndIf
							EndIf
						EndIf

						If monster\box = Null 
							monster\y = monster\y + monster\yd
							If monster\yd>=0.0						
								For box.box = Each box
									If RectsOverlap(monster\x+8,monster\y,1,16,box\x,box\y,box\w,box\h) = False
										If RectsOverlap(monster\x+8,monster\y+monster\yd+1,1,16,box\x,box\y,box\w,box\h)
											monster\box = box
											monster\y = box\y-16
											Exit
										EndIf							
									EndIf
								Next
							EndIf
							monster\yd = monster\yd * 0.99 + 0.1								
						Else
							If monster\x+6>monster\box\x+monster\box\w
								monster\box = Null
								monster\yd = 0
							ElseIf monster\x+10<monster\box\x
								monster\box = Null
								monster\yd = 0
							EndIf	
						EndIf					
					EndIf
				EndIf
			EndIf
			
			If player\dying = 0		
				dx#=((monster\x+8)-player\x)
				dy#=(monster\y+8-player\y)
				If (dx*dx+dy*dy)<32*32
					
					If Sin(MilliSecs())>0
						Outline_text player\x,player\y-30,"Watch out!",1,1
					EndIf
						
				EndIf
				
				If RectsOverlap(Player\x-2,Player\y-2,5,5,monster\x,monster\y,16,16)
					If player\shieldtime = 0
						;LoseLife(player)
						player\dying = 1
						player\yd = -3
						player\xd = 0
						m.message = New message
						m\x = player\x
						m\y = player\y - 16
						m\life = 100
						m\txt = "EEK!"
						channel = PlaySound(die)
					End If
				ElseIf monster\y > GraphicsHeight()
					Delete monster
				End If
			EndIf
		End If
	Next
	
End Function


Here's a mean predator level for an example:
Data 7								; the level number
Data "Warning: Predators!"			; the level name
Data 1777							; the level seed
Data 3500							; the level height
Data 0.2							; Initial scrollspeed
Data 2								; Monster random number (lower = more monsters)
Data 3								; Monster types ....
Data 1								; Coin random number (lower = more coins)
Data 7								; Diamond random number (lower = more diamonds)
Data 250							; Rock random number (lower = more rocks)
Data 30								; Number of platforms
Data 5000							; Treasure Chest Value