Skip to content

Commit

Permalink
some gfx
Browse files Browse the repository at this point in the history
  • Loading branch information
javisantana committed Sep 18, 2011
1 parent 829af18 commit 99fc4ee
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions public/game1/bullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Bullet.prototype.update = function(dt) {
Bullet.prototype.render = function(ctx) {
var p = this.pos;
var p0 = this.oldpos;
ctx.fillStyle = "rgb(157, 170, 195)";
ctx.fillRect(p.x, p.y, 2, 2);
/*
ctx.beginPath();
Expand Down
Binary file added public/game1/img/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion public/game1/lines.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<title>G</title>
<style>
body {
background-color: #555;
height: 100%;
background: -webkit-gradient(
radial, 500 25%, 20, 500 25%, 40, from(rgb(2, 5, 6)), to(rgb(13, 31, 44))
);
background: #111;
}
</style>
<meta charset="utf-8" />
Expand Down
19 changes: 8 additions & 11 deletions public/game1/particles.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@


function Explosion(pos) {


for(var i=0; i < 100; ++i)
for(var i=0; i < 100; ++i) {
entities.add({

pos: pos,
vel: vec2.fromAngle(rand01()*360),
life: 0.1 + rand01(),
v: 1.0 + rand01(),
life: rand01()*0.01,
time: 0,

update: function(dt) {
var p = this;
p.pos = vec2.add(p.pos, vec2.mul(dt, p.vel));

//var v = 1.0 - smoothstep(0, 300, p.time);
var v = clamp(0, 1, p.life*100.0/p.time);
this.vel = vec2.mul(v, p.vel);
return v > 0.4;
p.time += dt;
p.v += (0 - p.v)*dt*p.life;
p.pos = vec2.add(p.pos, vec2.mul(dt, vec2.mul(p.v*0.2, p.vel)));
return p.v > 0.1;
},

render: function(c) {
Expand All @@ -27,4 +23,5 @@ function Explosion(pos) {
c.fillRect(p.x, p.y, 1, 1);
}
});
}
}
9 changes: 8 additions & 1 deletion public/game1/player.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@


var img = document.createElement("img");
img.src = '/img/player.png';
img.width = '32px';
img.height = '32px';


var Player = function(pos, controller) {
this.pos = pos;
this.angle = 0;
Expand Down Expand Up @@ -28,6 +34,7 @@ Player.prototype.update = function(dt) {

Player.prototype.render = function(ctx) {
var p = this.pos;
ctx.fillRect(p.x, p.y, 10, 10);
//ctx.fillRect(p.x, p.y, 10, 10);
ctx.drawImage(img, p.x, p.y, 32, 32);
};

0 comments on commit 99fc4ee

Please sign in to comment.