User Tools

Site Tools


en:guides:beginners:jelly_monsters

Part 16 - Jelly Monsters

We need something to create challenge in the game. Alien jelly monsters are the obvious choice. Lots of them. Here's a sprite sheet for the monsters:

Right click and save to the data/texture folder in our project as “monster.png”.

Create a graphic from the sprite sheet in the config:

[MonsterGraphic]
Texture		= monster.png
TextureOrigin	= (0, 0, 0) ;required by the animation system for sizing.
TextureSize	= (32, 32, 0)
Pivot		= center

We need an object:

[MonsterObject]
Graphic      = MonsterGraphic
AnimationSet = MonsterAnimationSet
Position     = (-310, -210, 0)
Scale        = 2.0

Then to define the animation set and the one animation we need:

[MonsterAnimationSet]
Texture			= monster.png
KeyDuration             = 0.1
FrameSize		= (32, 32, 0)
MonsterWobbleAnim	= -1 ;use the entire sheet
StartAnim		= MonsterWobbleAnim
MonsterWobbleAnim->	= MonsterWobbleAnim
Pivot			= center

Just so you can see the monster working… add a MonsterObject to the Scene childlist:

[Scene]
ChildList = PlatformObject # MiddlePlatformObject #
TopLeftPlatformObject # TopPlatformObject #
TopRightPlatformObject #
StarObject # MonsterObject

Run the game and you'll see a monster wobbling in the top left hand corner of the screen:

We need more than one monster, very soon we'll make lots of them drop out of the sky.

Last job is to give the monster a body and ensure he collides with platforms, bullets, and our hero:

[MonsterObject]
Graphic      = MonsterGraphic
AnimationSet = MonsterAnimationSet
Position     = (-310, -210, 0)
Scale        = 2.0
Body         = MonsterBody
 
[MonsterBody]
Dynamic  = true
PartList = MonsterBodyPart
 
[MonsterBodyPart]
Type        = box
Solid       = true
SelfFlags   = monster
CheckMask   = hero # platforms # bullet

And add monster to the PlatformBody so that collisions work on both object types:

[PlatformBodyPart]
Type        = box
Solid       = true
SelfFlags   = platforms
CheckMask   = hero # monster

Run it again and the monster should drop down onto a platform.


Next: Part 17 – Timeline Tracks.

en/guides/beginners/jelly_monsters.txt · Last modified: 2024/11/19 02:30 (48 hours ago) by sausage