44
Youssif Daif

Game age ppt

Embed Size (px)

DESCRIPTION

my session on DEVENT2 @DEVMIX Team With Ahmed Daif

Citation preview

Page 1: Game age ppt

YoussifDaif

Page 2: Game age ppt

Education !!

Page 3: Game age ppt

gametutorials

aplusmath

Visualmaththreading

vectorkids

Page 4: Game age ppt
Page 5: Game age ppt

Simulation

Page 6: Game age ppt
Page 7: Game age ppt
Page 8: Game age ppt

real   Business

Page 9: Game age ppt

70,000,000

Page 10: Game age ppt
Page 11: Game age ppt
Page 12: Game age ppt
Page 13: Game age ppt

gaming hardware 17,797

gaming software 44,730

online gaming 11,899

Total 74,426

Page 14: Game age ppt

types...

Page 15: Game age ppt

vs

Page 16: Game age ppt

logic

Page 17: Game age ppt

Sports

Page 18: Game age ppt

Strategy

Page 19: Game age ppt

Shooting

Page 20: Game age ppt

Racing

Page 21: Game age ppt

Online  OR  Web

Page 22: Game age ppt

1,000,000,000 $

Online games sales66 B $

Page 23: Game age ppt

no programming language ..!

Page 24: Game age ppt

Components ...

Page 25: Game age ppt

Let's Play ...

Page 26: Game age ppt

Welcome!Catch Devmix

Page 27: Game age ppt

What Do First?• Create HTML File With name index.html

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>catch Devmix </title></head><body><script src="js/game.js"></script></body><html/>

Page 28: Game age ppt

And Then• Create game.js file and Put this

var canvas = document.createElement("canvas");var ctx = canvas.getContext("2d");canvas.width = 512;canvas.height = 480;document.body.appendChild(canvas);//Here We create Canvas With required Deminsion

Page 29: Game age ppt

Put Background and our characters

• First put Background :-var bgReady = false;var bgImage = new Image();bgImage.onload = function () {bgReady = true;};bgImage.src = "images/background.png";

Page 30: Game age ppt

Put Background and our characters

• Then Create The Hero :) :-var heroReady = false;var heroImage = new Image();heroImage.onload = function () {heroReady = true;};heroImage.src = "images/hero.png";

Page 31: Game age ppt

Put Background and our characters

Then Create DX (The queen) :-var dxReady = false;var dxImage = new Image();dxImage.onload = function () {dxReady = true;};dxImage.src = "images/dx.png";

Page 32: Game age ppt

Put Background and our characters

• Then Create Our Enemy if it was hard or very hard :-var monsterReady = false;var monsterImage = new Image();monsterImage.onload = function () {monsterReady = true;};monsterImage.src = "images/monster.png";

Page 33: Game age ppt

Define Game Objects

var hero = {speed: 256 // movement in pixels per second};var monster = {};var dx ={}var dxCaught = 0;var lvl,mover0,mover1;

Page 34: Game age ppt

Handle keyboard controls

var keysDown = {};addEventListener("keydown", function (e) {keysDown[e.keyCode] = true;}, false);addEventListener("keyup", function (e) {delete keysDown[e.keyCode];}, false);

Page 35: Game age ppt

Draw everything

var render = function () {if (bgReady) {ctx.drawImage(bgImage, 0, 0);}if (heroReady) {ctx.drawImage(heroImage, hero.x, hero.y);}if (monsterReady) {ctx.drawImage(monsterImage, monster.x, monster.y);}if (dxReady) {ctx.drawImage(dxImage, dx.x, dx.y);}

Page 36: Game age ppt

Draw everything

//scorectx.fillStyle = "rgb(250, 250, 250)";ctx.font = "24px Helvetica";ctx.textAlign = "left";ctx.textBaseline = "top";ctx.fillText("Goblins caught: " + monstersCaught, 32, 32);};

Page 37: Game age ppt

Reset the game when the Hero catches a enemy

var reset = function () {clearInterval(mover0);clearInterval(mover1);hero.x = canvas.width / 2;hero.y = canvas.height / 2;// Throw the dx somewhere on the screen randomlydx.x = 32 + (Math.random() * (canvas.width - 94));dx.y = 32 + (Math.random() * (canvas.height - 94));If(lvl > 0)mover0 = setInterval(??);

Page 38: Game age ppt

Reset the game when the Hero catches a enemy

// Throw the monster somewhere on the screen randomly//if it was hard or very hardIf(lvl > 2){monster.x = 32 + (Math.random() * (canvas.width - 94));monster.y = 32 + (Math.random() * (canvas.height - 94));mover1 = setInterval(??);}};

Page 39: Game age ppt

Let's play this game!

reset();var then = Date.now();setInterval(main, 1); // Execute as fast as possible

Page 40: Game age ppt

The main game loop

var main = function () {var now = Date.now();var delta = now - then;update(delta / 1000);render();then = now;};

Page 41: Game age ppt

Update game objects

var update = function (modifier) {if (38 in keysDown) { // Player holding uphero.y -= hero.speed * modifier;}if (40 in keysDown) { // Player holding downhero.y += hero.speed * modifier;}if (37 in keysDown) { // Player holding lefthero.x -= hero.speed * modifier;}if (39 in keysDown) { // Player holding righthero.x += hero.speed * modifier;}

Page 42: Game age ppt

Update game objects

//Are they touching?if (hero.x <= (dx.x + 32)&& dx.x <= (hero.x + 32)&& hero.y <= (dx.y + 32)&& dx.y <= (hero.y + 32)) {++dxCaught;reset();}

Page 43: Game age ppt

Update game objects

if(lvl > 2 && hero.x <= (monster.x + 32)&& monster.x <= (hero.x + 32)&& hero.y <= (monster.y + 32)&& monster.y <= (hero.y + 32)) {reset();}};

Page 44: Game age ppt

End & Questions

?Thanks