Custom Movement Improvement!
Author: | Assault Andy
|
Submitted: | 16th May, 2003
|
Views: | 7783
| Rated: |
|
|
Hey everyone, this is intermediate stuff, and i'll try to include a bit of advanced. It will include bouncing objects, combinding values with position, gravity. Let's get started.
What is custom movement?
Custom movement is programming from (near) scratch. We don't use the built-in engines such as racing car or 8-direction. Custom movement uses x and y positions to move from place to place.
Why use it?
Using custom movement allows you to do things you normally wouldn't be able to do in built-in movements. You can make jetpacks, bouncing balls (up and down), walk on walls, slo motion, and all kinds of other things. Some of this I admit can be done with default movement, but it usually comes out better with custom.
Intermediate
Basic Bouncing Ball
Let's start with making a bouncing ball that bounces from the left of the screen to the right.
Open your click product, you will need TGF or MMF. I am making this is MMF but tgf is fine, we won't be using any extensions.
Start a new application, add an active object and add a background object (about 200 in height). For the active object draw some sort of ball and place it in the middle of the screen. For the background object just make it a solid colour, Set it to an obstacle and make it cover the bottom of the screen with no gaps on the side.
Now open you event editor. We are going to be using alterable values if you don't know what they are i am going to give a short explanation. If you know what they are, move on.
Alterable values are just counters except they are internal. Meaning that every active object has one and each alterable value for each active object can have a differant value. Active objects have 26 differant Alt values which are listed A-Z.
We are going to create some events now, so i'll list them.
Always - (Ball) set Y to Y( Ball ) - Alterable Value A( Ball )
- subtract 1 from alt value A (Ball)
- (Ball) Set X to X ( Ball ) + Alterable Value B( Ball )
Ball is overlapping a backdrop - (ball)add 12 to alterable value A
Start of frame - (ball) set alt val B to 1.
Now for some collisions
Ball X <= 0 - set alt val B to alt val B * -1
Ball X => frame width - (insert ball's width here) - set alt val B to alt val B * -1
Multiplying something by -1 inverts it.
This is a simple bouncing ball movement, all the values can be edited so fiddle round with it.
More complex Bouncing Ball
For a bouncing ball that gradually bounces lower and lower, have it so when the ball overlaps the floor, it adds alt val c. And when it collides with the floor, it subtracts one from alt val C. Then all you have to do is have at the start of the frame set alt val c to 6 or something. This will make the ball start bouncing huge then get lower and lower.
This is a meteor type engine i made. It has gravity and uses the same movement as the bouncing ball except it is player controlled.
http://www.create-games.com/download.asp?id=2766
Collision detection
A problem with custom movement is you have to create your own type of collision detection. Collision detection
is when you detect if a player has touched a wall or another obstacle. To acomplish this we need to use detectors.Usually people use 4 active objects, and put one on each side of the player but I have created a new way of detecing for objects on all sides, without using detectors . I will just upload the open source because I don't want to type it all out. It is very simple though.
It's a .cca soz tgfers.
http://ccsoft.serveftp.net/group/news/upload/files/No%20Detection.cca
That .cca has all the neccesarys for creating a basic custom movement 8-direction.
I hope you learnt something toodaloo!
-Andy (12,ccsoft)
|
|
|