new engine.js

This commit is contained in:
John Alanbrook 2023-05-26 02:56:12 +00:00
parent 4a4c355fe8
commit 43ae50e9a2
2 changed files with 28 additions and 10 deletions

View file

@ -98,6 +98,11 @@ var paddle = gameobject.clone("paddle", {
speed: 1000,
length: 50,
height: 28,
lengths: [50,70,100,130,150],
size: 0,
input_larrow_down() { this.input_a_down(); },
frame_vel: [0,0],
@ -110,6 +115,10 @@ var paddle = gameobject.clone("paddle", {
this.frame_vel = this.frame_vel.add([1,0]);
},
draw() {
Debug.box(this.pos, [this.length, this.height], Color.white);
},
update(dt) {
this.angle = 0;
this.pos = this.pos.add(this.frame_vel.scale(this.speed*dt)).map(p => Math.clamp(p, -max_x, max_x));
@ -123,6 +132,16 @@ var paddle = gameobject.clone("paddle", {
setup() {
Player.players[0].control(this);
this.length = this.lengths[0];
},
input_p_pressed() {
this.grow();
},
grow() {
this.size++;
this.length = this.lengths[this.size];
},
collide(hit) {

View file

@ -4,7 +4,6 @@
"selectable": false,
"phys": 1,
"speed": 300,
"_zoom": 1,
"speedmult": 1,
"from": "gameobject"
},
@ -26,20 +25,20 @@
},
"ball": {
"collider": {
"rradius": 4.39338754070273,
"radius": 4.39338754070273,
"ofset": [
0,
0
]
},
"img": {
"_pos": [
"pos": [
-0.5,
-0.5
],
"_path": "ball.png"
"path": "ball.png"
},
"_scale": 2.919193983078003,
"scale": 2.919193983078003,
"from": "gameobject"
},
"paddle": {
@ -54,14 +53,14 @@
"mirrorx": true
},
"img": {
"_pos": [
"pos": [
-0.5,
-0.5
],
"_path": "pill3.png"
"path": "pill3.png"
},
"from": "gameobject",
"_scale": 2.9100000858306885
"scale": 2.9100000858306885
},
"breakoutfield": {
"from": "edge2d",
@ -101,8 +100,8 @@
"loop": false
}
},
"_path": "brick.png",
"_pos": [ -0.5, -0.5 ]
"path": "brick.png",
"pos": [ -0.5, -0.5 ]
},
"pos": [
43,