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

View file

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