Move input to input object system
This commit is contained in:
parent
52d08ec085
commit
996dd96d50
|
@ -21,7 +21,7 @@ var f = World.spawn(gameobjects['edge2d']);
|
|||
f.edge2d.thickness = 10;
|
||||
f.edge2d.cpoints = Geometry.box(lvlwidth+f.edge2d.thickness*2,lvlheight);
|
||||
f.draw = function() {
|
||||
Debug.line(f.edge2d.points, Color.green, 0, f.edge2d.thickness*2);
|
||||
//Debug.line(f.edge2d.points, Color.green, 0, f.edge2d.thickness*2);
|
||||
};
|
||||
|
||||
Register.draw.register(f.draw,f);
|
||||
|
|
43
config.js
43
config.js
|
@ -106,18 +106,8 @@ var paddle = gameobject.clone("paddle", {
|
|||
max_x: 0,
|
||||
extents: 300,
|
||||
|
||||
input_larrow_down() { this.input_a_down(); },
|
||||
|
||||
frame_vel: [0,0],
|
||||
|
||||
input_a_down() {
|
||||
this.frame_vel = this.frame_vel.add([-1,0]);
|
||||
},
|
||||
|
||||
input_d_down() {
|
||||
this.frame_vel = this.frame_vel.add([1,0]);
|
||||
},
|
||||
|
||||
update(dt) {
|
||||
this.angle = 0;
|
||||
var fpos = this.pos;
|
||||
|
@ -180,17 +170,6 @@ var paddle = gameobject.clone("paddle", {
|
|||
stickball: {},
|
||||
stickpos: [0,0],
|
||||
|
||||
input_space_pressed() {
|
||||
if (this.sticky && this.stickball) {
|
||||
this.stickball.velocity = this.stored_vel;
|
||||
this.stickball = {};
|
||||
}
|
||||
|
||||
if (this.laser) {
|
||||
this.shoot();
|
||||
}
|
||||
},
|
||||
|
||||
start() {
|
||||
this.collider.sensor = true;
|
||||
},
|
||||
|
@ -217,6 +196,28 @@ var paddle = gameobject.clone("paddle", {
|
|||
},
|
||||
});
|
||||
|
||||
paddle.inputs = {};
|
||||
paddle.inputs.space = function() {
|
||||
if (this.sticky && this.stickball) {
|
||||
this.stickball.velocity = this.stored_vel;
|
||||
this.stickball = {};
|
||||
}
|
||||
|
||||
if (this.laser) {
|
||||
this.shoot();
|
||||
}
|
||||
};
|
||||
|
||||
paddle.inputs.a = function(){};
|
||||
paddle.inputs.a.down = function() {
|
||||
this.frame_vel = this.frame_vel.add([-1,0]);
|
||||
};
|
||||
|
||||
paddle.inputs.d = {};
|
||||
paddle.inputs.d.down = function() {
|
||||
this.frame_vel = this.frame_vel.add([1,0]);
|
||||
};
|
||||
|
||||
gameobject.clone("upgrade_drop", {
|
||||
fallspeed: 150,
|
||||
tag: "ball",
|
||||
|
|
2
game.js
2
game.js
|
@ -1,2 +1,2 @@
|
|||
Window.icon("powerup.png");
|
||||
load("startmenu.js");
|
||||
World.load("startmenu");
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
var startgame = function()
|
||||
{
|
||||
run("breakout.js");
|
||||
Player.players[0].uncontrol(startcontroller);
|
||||
Register.gui.unregister(startmenu);
|
||||
scene.kill();
|
||||
// Player.players[0].uncontrol(startcontroller);
|
||||
// Register.gui.unregister(startmenu,this);
|
||||
};
|
||||
|
||||
var exitgame = function()
|
||||
|
@ -70,7 +71,7 @@ function startmenu() {
|
|||
GUI.image_fn({path:"coin.png", anchor: [1,0.5]}).draw([item.bb.l, (item.bb.b + item.bb.t)/2].add([-3,1]));
|
||||
}
|
||||
|
||||
Register.gui.register(startmenu);
|
||||
Register.gui.register(startmenu, scene);
|
||||
|
||||
var startcontroller = {};
|
||||
startcontroller.inputs = {};
|
||||
|
@ -92,4 +93,3 @@ startcontroller.inputs.enter = function() { Log.warn("TEST"); item.action(); };
|
|||
|
||||
Player.players[0].control(startcontroller);
|
||||
Game.play();
|
||||
|
||||
|
|
Loading…
Reference in a new issue