Permalink
Browse files

Shit removed

  • Loading branch information...
1 parent 826c5fb commit 2bea1ce5ef482795161d614404c9f2b2a6ff84db Konstantin Molchanov committed Mar 23, 2012
Showing with 0 additions and 500 deletions.
  1. +0 −23 index.html~
  2. +0 −85 js/bullet.js~
  3. +0 −45 js/bullets.js~
  4. +0 −67 js/controller.js~
  5. +0 −164 js/enemy.js~
  6. +0 −116 js/player.js~
View
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<html style="color:white;background:#111;">
- <head>
- <meta charset="utf-8" />
- <title>Catch</title>
-
- <!-- Libs -->
- <script type="text/javascript" src="./js/lib/atom.js"></script>
- <script type="text/javascript" src="./js/lib/libcanvas.js"></script>
-
- <script src="./js/init.js"></script>
- <script src="./js/collection.js"></script>
- <script src="./js/controller.js"></script>
- <script src="./js/bullet.js"></script>
- <script src="./js/bullets.js"></script>
- <script src="./js/player.js"></script>
- <script src="./js/enemy.js"></script>
- <script src="./js/enemies.js"></script>
- </head>
- <body>
- <canvas></canvas>
- </body>
-</html>
View
@@ -1,85 +0,0 @@
-TextGalactic.BulletTypes = {
- simple: {
- text: ".",
- rate: 10,
- speed: 450,
- color: "#ccc"
- },
- big: {
- text: "o",
- rate: 5,
- speed: 100,
- color: "#ccc"
- },
- rocket: {
- text: "^",
- rate: 3,
- speed: 100,
- color: "#ccc"
- },
- lazer: {
- text: "|",
- rate: 3,
- speed: 300,
- color: "#ccc"
- }
-};
-
-TextGalactic.Bullet = atom.Class(
-/**
- * @lends TextGalactic.Bullet#
- * @augments LibCanvas.Scene.Element#
- */
-{
- Extends: LibCanvas.Scene.Element,
-
- direction: 'up',
-
- type: TextGalactic.BulletTypes['simple'],
-
- /** @constructs */
- initialize: function (scene, options) {
- this.parent(scene, options);
- this.moveSpeed = (this.type.speed);
- this.type = options.type;
- this.direction = options.direction;
- },
-
- getContainer: function () {
- return this.scene.resources.rectangle.clone().grow( -this.shape.radius*2 );
- },
-
- onUpdate: function (time) {
- var moveSpeed = (this.moveSpeed * time).toSeconds().round();
-
- if (this.direction == 'up') {
- move(this, 0, -moveSpeed);
- this.options.bullets.checkEnemyCollision(this);
- } else {
- move(this, 0, moveSpeed);
- this.options.bullets.checkPlayerCollision(this);
- }
- // Deestroy bullet if it's the canvas
- if (
- this.shape._center.y > this.scene.resources.rectangle.to.y
- || this.shape._center.y < this.scene.resources.rectangle.from.y
- ) {
- this.destroy();
- }
- },
-
- explode: function (){
- this.destroy;
- this.options.bullets._destroy(this);
- },
-
- renderTo: function (ctx) {
- //ctx.fill( this.shape);
-
- ctx.fillStyle = this.type.color;
- ctx.font = "normal normal " + TextGalactic.Settings.font_size + "px courier";
- ctx.fillText(this.type.text, this.shape._center.x, this.shape._center.y);
-
- return this.parent();
- }
-});
View
@@ -1,45 +0,0 @@
-TextGalactic.Bullets = atom.Class({
-
- Extends: TextGalactic.Collection,
-
- initialize: function (scene, controller) {
- this.parent(scene, controller);
- this.storage = new Array();
- },
-
- _destroy: function(object) {
- for (i = 0; i < this.storage.length; i++) {
- if (this.storage[i] == object) {
- this.storage.splice(i, 1);
- }
- }
- },
-
- create: function (fromPoint, bullitType, direction) {
- var bullit = this.storage.push(new TextGalactic.Bullet(this.scene, {
- shape: new Circle(fromPoint, TextGalactic.Settings.font_size),
- type: bullitType,
- direction: direction,
- bullits: this
- }));
-
- return bullit;
- },
-
- checkPlayerCollision: function (bullit) {
- var player = this.controller.getPlayer();
-
- if (player.getCollisionRectangle(bullit.shape.radius).hasPoint(bullit.shape)) {
- player.hit();
- bullit.destroy();
- }
- },
-
- checkEnemyCollision: function (bullit) {
- var enemy = this.controller.getEnemies().find([bullit.shape._center.x, bullit.shape._center.y]);
-
- if (enemy !== null) {
- bullit.explode();
- }
- },
-});
View
@@ -1,67 +0,0 @@
-TextGalactic.Controller = atom.Class(
-/**
- * @lends TextGalactic.Controller#
- */
-{
- /** @constructs */
- initialize: function () {
- var app = new LibCanvas.App( 'canvas', {
- keyboard: true,
- width : 300,
- height : 450
- });
-
- this.drawBackground( app.libcanvas.ctx );
-
- this.activeScene = app.createScene( 'active' );
-
- this.player = this.createPlayer(new Point( 50, 430 ));
-
- this.enemies = new TextGalactic.Enemies(this.activeScene, this);
-
- this.bullets = new TextGalactic.Bullets(this.activeScene, this);
-
- this.createEnemies()
- },
-
- getBullets: function() {
- return this.bullets;
- },
-
- getPlayer: function() {
- return this.player;
- },
-
- getEnemies: function() {
- return this.enemies;
- },
-
- createEnemies: function () {
- this.getEnemies().create();
- this.getEnemies().create();
- this.getEnemies().create();
- this.getEnemies().create();
- this.getEnemies().create();
- },
-
- drawBackground: function (ctx) {
- ctx.fillAll(ctx.createGradient( ctx.rectangle, {
- '0.0': '#000'
- }));
- },
-
- createPlayer: function (center) {
- var player = {
- height: TextGalactic.Settings.font_size,
- width: TextGalactic.Settings.font_stretch
- }
-
- return new TextGalactic.Player( this.activeScene, {
- shape: new Rectangle({
- from: center.clone().move( [-player.width/2, -player.height/2] ),
- size: [player.width, player.height]
- }),
- controller: this
- });
- }
-});
View
@@ -1,164 +0,0 @@
-TextGalactic.Enemies = {
- 0: {
- text: "W",
- health: 100,
- speed: 150,
- },
- 1: {
- text: "T",
- health: 150,
- speed: 140,
- },
- 2: {
- text: "Y",
- health: 200,
- speed: 130,
- bulletType: TextGalactic.BulletTypes['big'],
- },
- 3: {
- text: "U",
- health: 250,
- speed: 120,
- },
- 4: {
- text: "I",
- health: 300,
- speed: 110,
- bulletType: TextGalactic.BulletTypes['lazer'],
- },
- 5: {
- text: "H",
- health: 350,
- speed: 100,
- },
- 6: {
- text: "X",
- health: 360,
- speed: 90,
- bulletType: TextGalactic.BulletTypes['simple'],
- },
- 7: {
- text: "V",
- health: 370,
- speed: 70,
- },
- 8: {
- text: "M",
- health: 380,
- speed: 50,
- bulletType: TextGalactic.BulletTypes['simple'],
- }
-}
-
-TextGalactic.Enemy = atom.Class(
-/**
- * @lends TextGalactic.Enemy#
- * @augments LibCanvas.Scene.Element#
- */
-{
- Extends: LibCanvas.Scene.Element,
-
- colors: {
- 3: {
- '0.0': '#f66',
- '1.0': '#900'
- },
- 2: {
- '0.0': '#ff6',
- '1.0': '#f60'
- },
- 1: {
- '0.0': '#6f6',
- '1.0': '#090'
- }
- },
-
- /** @constructs */
- initialize: function (scene, options) {
- this.parent( scene, options );
- this.addEvent( 'moveDrag', this.redraw );
- this.enemy = TextGalactic.Enemies[options.enemyType];
- this.speed = this.enemy.speed;
- this.health = this.enemy.health;
- this.dx = (getRandomInt(0, 1) == 0) ? 1: -1;
- this.dy = getRandomArbitary(0.8, 1.2);
- },
-
- getCollisionRectangle: function () {
- return this.shape;
- },
-
- rate: 0,
- health: 0,
-
- dx: 1,
- dy: -1,
-
- enemyType: 0,
-
- speed: TextGalactic.Settings.speed - 50 ,
-
- hit: function() {
- this.health = this.health - 100;
- this.redraw();
-
- if (this.health < 0) {
- return null;
- }
-
- return this;
- },
-
- normalize_d: function () {
- if (this.shape.from.y > this.scene.resources.rectangle.to.y) {
- this.kill();
- }
-
- if (this.shape.to.x > this.scene.resources.rectangle.to.x || this.shape.from.x < 0) {
- this.dx = -this.dx;
- }
-
- if (this.shape.from.y < -TextGalactic.Settings.font_size * 2) {
- this.dy = -this.dy;
- }
- },
-
- onUpdate: function (time) {
- var moveSpeed = (this.speed * time).toSeconds().round();
-
- move(this, this.dx * moveSpeed, this.dy * moveSpeed);
-
- this.normalize_d();
-
- // make shoot
- if (this.enemy.bulletType !== undefined) {
- if (this.rate > this.enemy.bulletType.rate * 4) {
- this.options.controller.getBullets().create(
- new Point(this.shape.from.x, this.shape.to.y),
- this.enemy.bulletType,
- 'down'
- );
-
- this.rate = 0;
- }
-
- this.rate++;
- }
- },
-
- renderTo: function (ctx) {
- //ctx.fill( this.shape, ctx.createRectangleGradient( this.shape, this.colors[this.lives] ));
- var healthq = Math.round(this.health/this.enemy.health * 255);
- ctx.fillStyle = "rgb(" + (healthq) + ", " + (healthq) + "," + (healthq) + ")";
-
- ctx.font = "normal normal " + TextGalactic.Settings.font_size + "px courier";
- ctx.fillText(this.enemy.text, this.shape.from.x, this.shape.to.y);
-
- return this.parent();
- },
-
- kill: function () {
- this.destroy();
- this.options.enemies._destroy(this);
- }
-});
Oops, something went wrong.

0 comments on commit 2bea1ce

Please sign in to comment.