User Tools

Site Tools


en:guides:beginners:exploding_monsters

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:guides:beginners:exploding_monsters [2018/02/13 20:47 (7 years ago)] – ↷ Links adapted because of a move operation iarwainen:guides:beginners:exploding_monsters [2024/11/19 03:17 (5 months ago)] (current) – Highlights sausage
Line 5: Line 5:
 {{ :guides:beginners:jelly.png?nolink |}} {{ :guides:beginners:jelly.png?nolink |}}
  
-Right click and save this image into the data/anim folder as "jelly.png".+Right click and save this image into the ''data/texture'' folder of our project as "jelly.png".
  
 Every monster will explode into several of these jelly objects when shot. Every monster will explode into several of these jelly objects when shot.
Line 19: Line 19:
 </code> </code>
  
-Then an individual JellyObject:+Then an individual ''JellyObject'':
  
 <code=ini> <code=ini>
Line 26: Line 26:
 AnimationSet = JellyAnimationSet AnimationSet = JellyAnimationSet
 Speed        = (-50, -50, 0) ~ (50, -50, 0) Speed        = (-50, -50, 0) ~ (50, -50, 0)
-Position     = (400, 0, 0)+Position     = (0, -300, 0)
 Body         = JellyBody Body         = JellyBody
 </code> </code>
Line 43: Line 43:
  
 [JellyWobbleAnim] [JellyWobbleAnim]
-KeyDuration = 0.05+KeyDuration = 0.08
  
 </code> </code>
  
-Then the jelly needs a body. This is so the bits will bounce nicely over the platforms:+The jelly needs a body. This is so the bits will bounce nicely over the platforms:
  
 <code=ini> <code=ini>
Line 62: Line 62:
 </code> </code>
  
-Then let the platforms know about the jelly mask:+Then let the platforms know about the jelly, by adding it the platform'mask:
  
-<code=ini>+<code=ini [highlight_lines_extra="5"]>
 [PlatformBodyPart] [PlatformBodyPart]
 Type        = box Type        = box
Line 74: Line 74:
 Test it by adding a JellyObject to the Scene section: Test it by adding a JellyObject to the Scene section:
  
-<code=ini>+<code=ini [highlight_lines_extra="5"]>
 [Scene] [Scene]
 ChildList = PlatformObject # MiddlePlatformObject # ChildList = PlatformObject # MiddlePlatformObject #
Line 88: Line 88:
  
  
-That's not bad, but really... the animation frame setup isn't quite what we're after. In our ''JellyAnimationSet'' we're just letting Orx automatically take the three frames in the sprite sheet. But really, we need four frames:+That's not bad, but really... the animation frame setup isn't quite what we're after. In our ''JellyAnimationSet'' we're just letting Orx automatically take the three frames in the sprite sheet. We really need four frames:
  
   * Frame 1   * Frame 1
Line 95: Line 95:
   * Frame 3   * Frame 3
  
-That is how the animation should be. Thankfully Orx will let us specify the frames for an animation manually. Add the following config to set this up:+That is how the animation should be. Thankfully Orx will let us specify the third and fourth frames for an animation manually. Add the following config to set this up:
  
 <code=ini> <code=ini>
-[JellyWobbleAnim0003]+[JellyWobbleAnim3]
 TextureOrigin = (0, 0, 0) TextureOrigin = (0, 0, 0)
  
-[JellyWobbleAnim0004]+[JellyWobbleAnim4]
 TextureOrigin = (64, 0, 0) TextureOrigin = (64, 0, 0)
 </code> </code>
  
-Great. By using the name of the animation (''JellyWobbleAnim'') + the frame number, now frames 3 and 4 are overriden in the sheet while frames 1 and 2 are picked up automatically by Orx.+Great. By using the name of the animation (''JellyWobbleAnim'') + the frame number, now frames 3 and 4 are overridden in the sheet while frames 1 and 2 are picked up automatically by Orx.
  
-The next step is to create an explosion object. This will be an empty object that contains a spawner. The spawner will shoot out five jellys. These explosion objects can be placed on any monster for dramatic effect:+The next step is to create an explosion object. This will be an empty object that contains a spawner. The spawner will shoot out five jellies. These explosion objects can be placed on any monster for dramatic effect:
  
 <code=ini> <code=ini>
Line 122: Line 122:
 To test one of the these, remove the JellyObject from the Scene section and add the JellyExploder instead: To test one of the these, remove the JellyObject from the Scene section and add the JellyExploder instead:
  
-<code=ini>+<code=ini [highlight_lines_extra="5"]>
 [Scene] [Scene]
 ChildList = PlatformObject # MiddlePlatformObject # ChildList = PlatformObject # MiddlePlatformObject #
Line 137: Line 137:
 Great, we see a bunch of jelly blobs appear. Remove the JellyExploder from the Scene selector: Great, we see a bunch of jelly blobs appear. Remove the JellyExploder from the Scene selector:
  
-<code=ini>+<code=ini [highlight_lines_extra="5"]>
 [Scene] [Scene]
 ChildList = PlatformObject # MiddlePlatformObject # ChildList = PlatformObject # MiddlePlatformObject #
Line 146: Line 146:
 </code> </code>
  
-Also remove the Position parameter from the JellyObject because these will soon be dynamically placed. Also change the Speed parameter to be more dramatic:+Also remove the ''Position'' parameter from the ''JellyObject'' because these will soon be dynamically placed. Also change the ''Speed'' parameter to be more dramatic:
  
 <code=ini> <code=ini>
Line 158: Line 158:
 Next, we need to ensure that the BulletObject has a body and that it can collide with a monster: Next, we need to ensure that the BulletObject has a body and that it can collide with a monster:
  
-<code=ini>+<code=ini [highlight_lines_extra="4"]>
 [BulletObject] [BulletObject]
 Graphic  = BulletGraphic Graphic  = BulletGraphic
Line 164: Line 164:
 Scale    = 0.25 Scale    = 0.25
 Body     = BulletBody Body     = BulletBody
 +
  
 [BulletBody] [BulletBody]
Line 176: Line 177:
 </code> </code>
  
-The bullets are not affected by gravity (Dynamic) nor do they bounce off other objects (Solid).+The bullets are not affected by gravity (not Dynamic) nor do they bounce off other objects (not Solid).
  
 In order to make a monster explode, we can make a function in the code which will create a exploder object on top off a monster object, and then destroy the monster itself: In order to make a monster explode, we can make a function in the code which will create a exploder object on top off a monster object, and then destroy the monster itself:
Line 196: Line 197:
 </code> </code>
  
-We are passing in a named exploderObjectName so that we can use this function later for other exploders we'll make.+We are passing in a named exploderObjectName so that we can re-use this function later for other exploders we'll make.
  
  
 Now to use it. In the physics event, add a check for collision between a bullet and a monster and process it: Now to use it. In the physics event, add a check for collision between a bullet and a monster and process it:
  
-<code=cpp>+<code=cpp [highlight_lines_extra="5,6,7,8,9,11,12,13,14,15"]> 
 +if (orxString_Compare(recipientObjectName, "StarObject") == 0){ 
 +    orxObject_SetLifeTime(pstRecipientObject, 0); 
 +
 +    
 if (orxString_Compare(senderObjectName, "BulletObject") == 0){ if (orxString_Compare(senderObjectName, "BulletObject") == 0){
     CreateExplosionAtObject(pstRecipientObject, "JellyExploder");     CreateExplosionAtObject(pstRecipientObject, "JellyExploder");
Line 215: Line 220:
 </code> </code>
  
-So in both cases, create the JellyExplosion on top of a monster, then destroy both the monster and the bullet that hit it.+So in both cases, create the ''JellyExplosion'' on top of a monster, then destroy both the monster and the bullet that hit it.
  
 Compile and run. You'll get some crazy jelly action all over the screen: Compile and run. You'll get some crazy jelly action all over the screen:
Line 221: Line 226:
 {{:guides:beginners:beginners-45-jelly-explosions.png?nolink|}} {{:guides:beginners:beginners-45-jelly-explosions.png?nolink|}}
  
-The jelly blobs never dissapear. Fix that by giving it a specific lifetime:+The jelly blobs never disappear. Fix that by giving it a specific lifetime:
  
-<code=ini>+<code=ini [highlight_lines_extra="6"]>
 [JellyObject] [JellyObject]
 Graphic      = JellyGraphic Graphic      = JellyGraphic
en/guides/beginners/exploding_monsters.1518583677.txt.gz · Last modified: 2018/02/14 00:47 (7 years ago) (external edit)