Â
If you have some questions you can ask me via email : lochost@mail.com
1) Jumping and falling behaviors.
2) Collide with other objects
3) Behaviors of other characters
4) Homing bullets for the reporters
5) and others...
class Stopwatch {
constructor() {
this.startTime = 0;
this.running = false;
this.elapsed = null;
}
start() {
}
stop() {
}
getElapsedTime() {
}
isRunning() {
}
reset() {
}
}
The main tool for creation jump and fall behaviors is stopwatch class. Which count ascending and descending time of jumping and falling.
1) Store left,right,top,bottom and center points of player
2) Use context.isPointInPath() method to reveal collision
ctx.isPointInPath(left,top) ||
ctx.isPointInPath(right,top) ||
ctx.isPointInPath(centerX,centerY) ||
ctx.isPointInPath(left,bottom) ||
ctx.isPointInPath(right,bottom)
To create new character you just need to use Sprite class and store into it one or more behaviors (jump,fire,run) which are classes too.
papparazzi = new Sprite('papparazzi',pappaArtist,
[paceBehavior,new cycleBevior(20,1500),new bounceBehaviour(2000,120)]);
y
x
tan = y/x
x1
y1
y1 = tan*x1