Gameplay trailer

Created by

 

Alexey Astafiev

 

If you have some questions you can ask me via email : lochost@mail.com

NO FRAMEWORKS!

JavaScript

+

HTML5

+

CSS3

The most complicated problems:

1) Jumping and falling behaviors.

2) Collide with other objects

3) Behaviors of other characters

4) Homing bullets for the reporters

5) and others...

Jumping and falling behaviors

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.

Collide with other objects

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)

Behaviors of other characters

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)]);

Homing bullets for the reporters

y

x

tan = y/x

x1

y1

y1 = tan*x1