Skip to content

Commit

Permalink
Update/delete stuff that didn't go into the last commit b/c i'm a noob
Browse files Browse the repository at this point in the history
  • Loading branch information
bisrael committed Mar 25, 2012
1 parent 13b46cc commit 7c2071c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2,091 deletions.
22 changes: 14 additions & 8 deletions Engine.dart
@@ -1,7 +1,8 @@
#library("Phart"); #library ('Phart');

#import ('dart:html'); #import ('dart:html');
#import ("RK4.dart"); #import ('Phart.dart');
#import ('Vector.dart'); #import ("Cube.dart");


class Game { class Game {
CanvasElement canvas; CanvasElement canvas;
Expand All @@ -23,7 +24,7 @@ class Game {
List<int> xs; List<int> xs;
List<int> ys; List<int> ys;


RkState particle; List<Cube2d> particles;


Game() { Game() {
canvas = document.query("#game"); canvas = document.query("#game");
Expand All @@ -44,15 +45,20 @@ class Game {
} }


void generateParticles() { void generateParticles() {
particle = new RkState(new Vector(_viewW/2.0, _viewH/2.0), new Vector(0.0,0.0)); particles = new List<Cube2d>();
} }


void updateParticles(double t, double dt) { void updateParticles(double t, double dt) {
particle = Rk4Integrator.integrate(particle, t, dt); particles.forEach((p){ p.update(t, dt); });
if(particles.length < 150 && !(t%1)) particles.add(new Cube2d.random());
} }


void drawParticles() { void drawParticles([final double alpha = 1.0]) {
_point(particle.x + _viewW/2.0, particle.y + _viewH/2.0, 9, 255, 0, 0, 1); context.save();
context.translate(_viewW/2, _viewH/2);
context.scale(30, 30);
particles.forEach((p){ p.render2d(context); });
context.restore();
} }


void start() { void start() {
Expand Down
24 changes: 7 additions & 17 deletions Phart.dart
@@ -1,18 +1,8 @@
#import('dart:html'); #library ("Phart");
#import('Engine.dart');


class PhartTest { #source ("PMath.dart");
Game game; #source ("Vector.dart");

#source ("Quaternion.dart");
PhartTest() { #source ("RkState.dart");
game = new Game(); #source ("RkDerivative.dart");
} #source ("RkIntegrator.dart");

void run() {
game.start();
}
}

void main() {
new PhartTest().run();
}

0 comments on commit 7c2071c

Please sign in to comment.