Skip to content

Commit

Permalink
Added too many things to count
Browse files Browse the repository at this point in the history
  • Loading branch information
64Mega committed Jan 14, 2018
1 parent f7164fc commit 65f1fec
Show file tree
Hide file tree
Showing 44 changed files with 1,386 additions and 122 deletions.
Binary file added assets/anims/blaster_shot/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/anims/blaster_shot/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/anims/blaster_shot/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bg_city.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/blast_shot_anim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/blaster_shot_static.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/crosshair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/door_locked1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/door_locked2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/door_locked3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/door_locked4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/door_static.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/font_main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gun_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/hud_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard_icon1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard_icon2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard_icon3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/keycard_icon4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/spr_font1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/testball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/wal_1.png
Binary file added assets/wal_10.png
Binary file added assets/wal_2.png
Binary file added assets/wal_3.png
Binary file added assets/wal_4.png
Binary file added assets/wal_5.png
Binary file added assets/wal_6.png
Binary file added assets/wal_7.png
Binary file added assets/wal_8.png
Binary file added assets/wal_9.png
Binary file added rawgfx/tiles.ase
Binary file not shown.
219 changes: 198 additions & 21 deletions rawmaps/map01.tmx

Large diffs are not rendered by default.

Binary file modified rawmaps/tmap.png
115 changes: 115 additions & 0 deletions src/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Generic input class


export default class Input {
constructor() {
this.canvas = document.getElementById("RenderCanvas");
this.isLocked = false;
this.canvas.addEventListener('click', (ev) => {
//if(this.isLocked === false) { this.canvas.requestPointerLock(); }
ev.preventDefault();
}, false);

document.addEventListener('pointerlockchange', (ev) => {
//this.isLocked = !this.isLocked;
//console.log("Cursor Lock changed to " + this.isLocked);
}, false);

this.keys = [];
for(let i = 0; i < 256; i++) {
this.keys[i] = 0;
}

document.addEventListener("keydown", (ev) => {
this.keys[ev.keyCode] = 1;
//console.log("Pressed " + ev.keyCode);
});

document.addEventListener("keyup", (ev) => {
this.keys[ev.keyCode] = false;
//console.log("Released " + ev.keyCode);
});

this.mouse = {
delta_x : 0,
delta_y : 0,
delta_xf : 0.0,
delta_yf : 0.0,
vel_x : 0.0,
vel_y : 0.0,
button_left: false,
button_right: false,
scroll_up: false,
scroll_down: false,
button_middle: false,
last_move_x: 0,
}

document.addEventListener("mousemove", (ev) => {
if(this.isLocked) {
if(this.mouse.last_move_x > 0 && ev.movementX < 0) {
ev.movementX = this.mouse.last_move_x;
}
if(this.mouse.last_move_x < 0 && ev.movementX > 0) {
ev.movementX = this.mouse.last_move_x;
}
this.mouse.delta_x = ev.movementX;
this.mouse.delta_y = ev.movementY;
this.mouse.delta_xf = (1 / 320) * ev.movementX;
this.mouse.delta_yf = (1 / 200) * ev.movementY;
}
});

document.addEventListener("mousedown", (ev) => {
this.mouse.button_left = ev.button_left;
this.mouse.button_right = ev.button_right;
});

document.addEventListener("mouseup", (ev) => {
this.mouse.button_left = ev.button_left;
this.mouse.button_right = ev.button_right;
});

setInterval(() => {
this.update();
}, 1000/60);
}

update() {
if(this.mouse.delta_x > 1) {
this.mouse.delta_x -= 1;
} else
if(this.mouse_delta_x < -1) {
this.mouse.delta_x += 1;
} else {
this.mouse.delta_x = 0;
}

if(this.mouse.delta_y > 0) {
this.mouse.delta_y -= 1;
} else {
this.mouse.delta_y += 1;
}

this.mouse.delta_xf = (1/320) * this.mouse.delta_x;
this.mouse.delta_yf = (1/240) * this.mouse.delta_y;

if(this.mouse.delta_xf > 1.0) { this.mouse.delta_xf = 1.0; }
if(this.mouse.delta_xf < -1.0) { this.mouse.delta_xf = -1.0; }
if(this.mouse.delta_yf > 1.0) { this.mouse.delta_yf = 1.0; }
if(this.mouse.delta_yf < -1.0) { this.mouse.delta_yf = -1.0; }

this.mouse.vel_x += this.mouse.delta_xf;
this.mouse.vel_y += this.mouse.delta_yf;
if(this.mouse.vel_x > 1.0) { this.mouse.vel_x = 1.0; }
if(this.mouse.vel_x < -1.0) { this.mouse.vel_x = -1.0; }
if(this.mouse.vel_y > 1.0) { this.mouse.vel_y = 1.0; }
if(this.mouse.vel_y < -1.0) { this.mouse.vel_y = -1.0; }

this.mouse.vel_x += -Math.sign(this.mouse.vel_x) * 0.1;
this.mouse.vel_y += -Math.sign(this.mouse.vel_y) * 0.1;

if(Math.abs(this.mouse.vel_x) <= 0.1) { this.mouse.vel_x = 0.0; }
if(Math.abs(this.mouse.vel_y) <= 0.1) { this.mouse.vel_y = 0.0; }
}
}
Loading

0 comments on commit 65f1fec

Please sign in to comment.