baardbi
Well-known member
Here is a tutorial on how to make the water splash when then player hits the surface, and how to make bubbles when the player is under water.
PS #1! Having a lot of splashing and bubbles in your game will cause a bit of slowdown.
PS #2! Using game objects for this is an expensive way to make effects, since you only have 16 game objects total.
Prerequisites for this tutorial:
- Basic understanding of NESmaker
- Knowledge about Game Objects and Tile Types
- Very basic understandig of ASM scripts
THE WATER SPLASH
1. First we need to decide which Game Object we will use as the splash. In this example I will use game object 8 (the default is Effect 0)
2. Give it a name so it's easy to identify it:
3. Make the animation of the splash. I use 6 frames in this example (it might be too much if you want a lot of game objects with big graphics)
4. Set a bounding box on your game object. Use the entire box as the bounding box:
5. In the Object Details window of the game object (under the tab Actions) set the following:
- Animation speed
- End Animation -> DestroyMe
- Ignore Gravity
6. Create a new ASM file called WaterSplash.asm (or whatever you like). Save it in the TileScripts folder of your game.
C:\Users\baardbi\Desktop\WaterSplashGame\GameEngineData\Routines\Basic\ModuleScripts\TileScripts\SimplePlatformer
7. Assign this file to the Tile Collision of your choice (I use Tile 11 in this example)
8. In Project Settings go to Project Labels and give a name to your new Tile type:
9. You can now create a new tile (asset) which will be the water surface:
Every time the player comes in contact with this tile a new game object (your water splash animation) will be created on the tile the player collided with.
THE WATER BUBBLES
Making bubbles when the player is under water is exactly the same process as above. The only difference is a slightly different code for the WaterBubbles.asm file:
In this example I use game object 9 for the water bubbles and Tile type 12 (see number 7 under The Water Splash tutorial).
Now you can make a new tile (asset) that acts as water. The bubbles (game objects) will be created constantly when the player collides with a water tile.
That's it!
A big thank you to Dale Coop for showing me how to get the position of the tiles the player collides with.
If you find any errors in this tutorial please let me know. Good luck making water effects in your game.
PS #1! Having a lot of splashing and bubbles in your game will cause a bit of slowdown.
PS #2! Using game objects for this is an expensive way to make effects, since you only have 16 game objects total.
Prerequisites for this tutorial:
- Basic understanding of NESmaker
- Knowledge about Game Objects and Tile Types
- Very basic understandig of ASM scripts
THE WATER SPLASH
1. First we need to decide which Game Object we will use as the splash. In this example I will use game object 8 (the default is Effect 0)
2. Give it a name so it's easy to identify it:
3. Make the animation of the splash. I use 6 frames in this example (it might be too much if you want a lot of game objects with big graphics)
4. Set a bounding box on your game object. Use the entire box as the bounding box:
5. In the Object Details window of the game object (under the tab Actions) set the following:
- Animation speed
- End Animation -> DestroyMe
- Ignore Gravity
6. Create a new ASM file called WaterSplash.asm (or whatever you like). Save it in the TileScripts folder of your game.
C:\Users\baardbi\Desktop\WaterSplashGame\GameEngineData\Routines\Basic\ModuleScripts\TileScripts\SimplePlatformer
Code:
;Water splash
CPX player1_object
BNE +
LDA tileX
AND #%11110000
STA temp
LDA tileY
AND #%11110000
SEC
SBC #$08 ;Adjust the splash to the top of the water tile
STA temp1
CreateObject temp, temp1, #$08, #$00, currentNametable ;Game Object 08 is the water splash
;PlaySound #SND_SPLASH
+
7. Assign this file to the Tile Collision of your choice (I use Tile 11 in this example)
8. In Project Settings go to Project Labels and give a name to your new Tile type:
9. You can now create a new tile (asset) which will be the water surface:
Every time the player comes in contact with this tile a new game object (your water splash animation) will be created on the tile the player collided with.
THE WATER BUBBLES
Making bubbles when the player is under water is exactly the same process as above. The only difference is a slightly different code for the WaterBubbles.asm file:
Code:
;;Water bubbles
LDX player1_object
LDA Object_x_hi,x
STA temp
LDA Object_y_hi,x
STA temp1
CreateObject temp, temp1, #$09, #$00, currentNametable
;LDA #$20
;STA GRAVITY_LO
In this example I use game object 9 for the water bubbles and Tile type 12 (see number 7 under The Water Splash tutorial).
Now you can make a new tile (asset) that acts as water. The bubbles (game objects) will be created constantly when the player collides with a water tile.
That's it!
A big thank you to Dale Coop for showing me how to get the position of the tiles the player collides with.
If you find any errors in this tutorial please let me know. Good luck making water effects in your game.