diff --git a/credits.html b/credits.html
index 16bf6ee..4fcfacb 100644
--- a/credits.html
+++ b/credits.html
@@ -36,7 +36,6 @@
Contributors
Gaeun Kim
Soumya Vadlamannati
Abishek V Ashok
-
Credits To:
diff --git a/flappy2.svg b/flappy2.svg
index b98abb2..69f7364 100644
--- a/flappy2.svg
+++ b/flappy2.svg
@@ -1,5 +1,5 @@
-
+
diff --git a/indexv2.html b/indexv2.html
new file mode 100644
index 0000000..3320e18
--- /dev/null
+++ b/indexv2.html
@@ -0,0 +1,15 @@
+
+
+ Flappy-SVG Game
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/javascript/background.js~ b/javascript/background.js~
deleted file mode 100644
index 487aaa8..0000000
--- a/javascript/background.js~
+++ /dev/null
@@ -1,177 +0,0 @@
-
-backgrounds = {};
-var obstacles;
-
-function background(layerName, velocity) {
- if (backgrounds[layerName]) {
- var background = backgrounds[layerName];
- if (velocity != undefined) background.velocity = velocity;
- return background;
- }
- return new Background(layerName, velocity);
-}
-
-function sign(number) {
- // Math.sign is not present in Internet Explorer.
- // We define this here so it works everywhere.
- if (number < 0) {
- return -1;
- } else if (number > 0) {
- return 1;
- } else if (number == 0) {
- return 0;
- }
- return null;
-}
-
-function Background(layerName, velocity) {
- this.layerName = layerName;
- this.layer = layerNamed(layerName);
- this.position = gameObject(this.layer);
- this.velocity = velocity;
- this.direction = sign(this.velocity)
- this.width = widthOfLayer(this.layer);
- var me = this;
- this.action = new Action(function(){me.move()}, function(){me.started()});
-
- backgrounds[this.layerName] = this;
-}
-
-Background.prototype = {
- startMoving : function() {
- this.action.start();
- },
- stopMoving : function() {
- this.action.stop();
- },
- move : function() {
- var x = this.position.x;
- x += this.velocity;
- if (x * this.direction > this.width) {
- x -= this.direction * this.width;
- }
- this.position.x = x;
- },
- started : function() {
- this.position.x = 0;
- },
- show : function() {
- this.position.show();
- },
- hide : function() {
- this.position.hide();
- },
- isVisible : function() {
- return this.position.isVisible();
- }
-}
-
-function startMovingBackgound(name, velocity) {
- var bg = background(name, velocity);
- if (bg.isVisible()) {
- bg.startMoving();
- }
-}
-
-function stopMovingBackgound(name) {
- background(name).stopMoving();
-}
-
-function stopAllBackgrounds(){
- for(var characters in backgrounds) {
- stopMovingBackgound(characters);
- }
- flappy.stopFlapping();
-}
-
-function backgroundChange(layer){
- desertHide()
- gothamHide()
- spaceHide()
- snowHide()
- seaHide();
-
- if (layer =='background'){
- desertShow()
- }
-
- if (layer =='Gotham'){
- gothamShow()
- }
-
- if (layer =='space'){
- spaceShow()
- }
- if (layer =='Snow'){
- snowShow()
- }
- if (layer =='Sea'){
- seaShow()
- }
-}
-
-function desertShow(){
- show_layer('cactus');
- show_layer('DayAndNight');
- show_layer('background');
- show_layer('SunAndMoon');
- show_layer('sky');
-
- createObstacles("cactus");
-}
-
-function desertHide(){
- hide_layer('cactus');
- hide_layer('DayAndNight');
- hide_layer('background');
- hide_layer('SunAndMoon');
- hide_layer('sky');
-}
-
-function gothamShow(){
- show_layer('Gotham');
- show_layer('Gotham_obstacles');
-
- createObstacles("Gotham_obstacles");
-}
-
-function gothamHide(){
- hide_layer('Gotham');
- hide_layer('Gotham_obstacles');
-}
-
-function spaceShow(){
- show_layer('space');
- show_layer('space_rocket');
-
- createObstacles("space_rocket");
-}
-
-function spaceHide(){
- hide_layer('space');
- hide_layer('space_rocket');
-}
-
-function snowShow(){
- show_layer('Snow');
- show_layer('Gifts');
-
- createObstacles("Gifts");
-}
-
-function snowHide(){
- hide_layer('Snow');
- hide_layer('Gifts');
-}
-
-function seaShow(){
- show_layer('Sea');
- show_layer('fishinghook');
-
- createObstacles("fishinghook");
-}
-
-function seaHide(){
- hide_layer('Sea');
- hide_layer('fishinghook');
-}
diff --git a/javascript/flapping.js~ b/javascript/flapping.js~
deleted file mode 100644
index f1bc65a..0000000
--- a/javascript/flapping.js~
+++ /dev/null
@@ -1,160 +0,0 @@
-function Flappy(layerName) {
- this.layerName = layerName;
- this.layer = layerNamed(layerName);
- this.position = gameObject(this.layer);
- this._isCollided = false;
- var me = this;
- this.action = new Action(function(){me.fly()}, function(){me.started()});
- document.onmousedown = function () { me.flap() };
-}
-
-Flappy.prototype = {
- velocity : 0,
- gravity : 1.8,
- flapVelocity : -20,
-
- startFlapping : function() {
- this.action.start();
- this.position.show();
- },
- stopFlapping : function() {
- this.action.stop();
- },
-
- fly : function() {
- this.velocity += this.gravity;
- this.position.y = this.position.y + this.velocity;
- if (this.position.screen.bottom > playfield().height) {
- this.position.screen.bottom = playfield().height;
- }
- if (this.position.screen.top < 0) {
- this.position.screen.top = 0;
- }
-
- this.checkCollision();
- },
- started : function() {
- this.position.y = 0;
- this.velocity = 0;
- },
- flap : function() {
- this.velocity = this.flapVelocity;
- var flapSound = new Audio("../flappy-svg/Sounds/Flappy.mp3");
- flapSound.play();
- },
- show : function() {
- this.position.show();
- },
- hide : function() {
- this.position.hide();
- },
-
- checkCollision : function() {
- var flappy_rect = this.layer.getBoundingClientRect();
- for (i = 0; i < 3; i++) {
- if (i >= obstacles.length)
- return;
- var o_rect = obstacles[i].getBox;
-
- var c = isOverlap(flappy_rect, o_rect);
-
- if(!c){
- var d = isBehind(o_rect,flappy_rect);
- if(d){
- updateScore();
- }
- } else {
- var gameOverSound = new Audio("../flappy-svg/Sounds/GameOver.mp3");
- gameOverSound.play();
- alert('Game Over :( Final Score: ' + Number(document.getElementById("score").innerHTML));
- }
-
- if (c || o_rect.right < flappy_rect.left)
- obstacles.push(obstacles.shift());
-
- this.isCollided = c;
- }
- },
-
- set isCollided(value){
- if (this._isCollided != value)
- this._isCollided = value;
-
- //On collision code here.
- if (this._isCollided)
- onCollision();
- },
-
- get isCollided(){
- return this._isCollided;
- }
-}
-
-var flappy = null;
-
-function characterChange(layer) {
- hide_layer('bird');
- hide_layer('bat');
- hide_layer('alien');
- hide_layer('flappydino');
- hide_layer('helicopter');
- hide_layer('rocket');
- hide_layer('Santa');
- hide_layer('Flappyfish');
- hide_layer('Super_rocket');
- flappy = new Flappy(layer);
- flappy.show();
-}
-
-function stopCharacterChange(){
-window.characterChange=function(){
- return false;
-}
-}
-
-function startFlapping(layer) {
- if (!flappy) {
- flappy = new Flappy(layer);
- }
- flappy.startFlapping();
-}
-
-function stopFlappingBackgound(name) {
- if (flappy) {
- flappy.stopFlapping();
- }
-}
-
-function getCenteredrect(rect){
- centered_rect = {
- x:rect.left+rect.width/2,
- y:rect.bottom+rect.height/2,
- width:rect.width,
- height:rect.height,
- };
- return centered_rect;
-}
-
-//Parameters are rects
-function isOverlap(e1, e2) {
- rect1 = getCenteredrect(e1);
- rect2 = getCenteredrect(e2);
- if (rect1.x < rect2.x + rect2.width &&
- rect1.x + rect1.width > rect2.x &&
- rect1.y < rect2.y + rect2.height &&
- rect1.height + rect1.y > rect2.y)
- return true;
- else return false;
-}
-
-function onCollision(){
- show_layer('gameover');
- stopAllBackgrounds();
-}
-
-function restartGame(){
- location.reload();
-}
-function isBehind(r1,r2){
- return (r1.right<=r2.left);
-}
diff --git a/javascript/levels.js~ b/javascript/levels.js~
deleted file mode 100644
index 9f6bdfd..0000000
--- a/javascript/levels.js~
+++ /dev/null
@@ -1,190 +0,0 @@
-function Level(name, backgrounds, obstacles){
- this._backgrounds = backgrounds;
- this.obstacles = obstacles;
- this._obstacles = createObstacles(obstaclesLayer);
- this._name = name;
- this._score = 0;
-}
-
-Level.prototype = {
-
- show: function(){
-
- for (background in this.backgrounds){
- show_layer(background["layer"]);
- }
-
- for(obstacle in this.obstacles){
- show_layer(obstacle["layer"]);
- }
-
- },
-
- hide: function(){
-
- for (background in this.backgrounds){
- hide_layer(background["layer"]);
- }
-
- for(obstacle in this.obstacles){
- hide_layer(obstacle["layer"]);
- }
-
- },
-
- getBackgrounds(): function(){
- return this._backgrounds;
- },
-
- getObstacles: function(){
- return this._obstacles;
- },
-
- getName(): function(){
- return this._name;
- },
-
- getScore(): function{
- return this_score;
- },
-
- start(): function(){
- //Needs to be Implemented
- },
-
- stop(): function(){
- // Needs to be Implemented
- },
-
-}
-
-var all_levels,current_level;
-
-// Specifications of any new level must be given here
-
-var all_level_specifications = {
- "desert":{
-
- "obstacles":[
- {
- "layer": "cactus",
- "velocity": 10,
- }
- ],
-
- "backgrounds":[
- {
- "layer" : "DayAndNight",
- "velocity" : -20
- },
- {
- "layer" : "background",
- "velocity" : -7
- },
- {
- "layer" : "SunAndMoon",
- "velocity" : 1
- },
- {
- "layer" : "sky",
- "velocity" : 0
- }
- ]
-
- },
-
- "gotham":{
-
- "obstacles":[
- {
- "layer":"Gotham_Obstacles",
- "velocity": -7
- }
- ],
-
- "backgrounds":[
- {
- "layer":"Gotham",
- "velocity": -7
- }
- ],
- },
-
- "space":{
-
- "obstacles":[
- {
- "layer":"space_rocket",
- "velocity": -7
- }
- ],
-
- "backgrounds":[
- {
- "layer":"space",
- "velocity": -7
- }
- ],
- },
-
- "Snow":{
-
- "obstacles":[
- {
- "layer":"Gifts",
- "velocity": -7
- }
- ],
-
- "backgrounds":[
- {
- "layer":"Snow",
- "velocity": -7
- }
- ],
- },
-
- "Sea":{
-
- "obstacles":[
- {
- "layer":"fishinghook",
- "velocity": -7
- }
- ],
-
- "backgrounds":[
- {
- "layer":"Sea",
- "velocity": -7
- }
- ],
- },
-
-};
-
-
-
-
-function getAllLevels(){
- return all_levels;
-}
-
-function newLevel(name,backgroundLayers,obstaclesLayer){
- return new Level(name,backgroundLayers,obstaclesLayer);
-}
-
-function setCurrentLevel(name){
- current_level = all_levels[name];
-}
-
-function getCurrentLevel(){
- return current_level;
-}
-
-window.onload = function() {
- for (level in all_level_specifications) {
- specs = all_level_specifications[level];
- all_levels[level] = newLevel(level, specs["backgrounds"], specs["obstacles"]);
- }
-}
diff --git a/javascript/start.js~ b/javascript/start.js~
deleted file mode 100644
index 249afee..0000000
--- a/javascript/start.js~
+++ /dev/null
@@ -1,19 +0,0 @@
-// Execute everything that should be started.
-// This script must be the last script. Otherwise not all functions may be loaded.
-
-
-
-window.onload = function() {
- scaleToFullscreen();
- showStartScreen();
-
- var characters = ["bird", "bat", "alien","flappydino","helicopter", "rocket","Santa", "Super_rocket", "Flappyfish", "Ball", "Blocky"];
- var backgrounds=["background","Gotham","space","Snow", "Sea"];
-
- rand=Math.floor((Math.random() * (backgrounds.length)));
- backgroundChange(backgrounds[rand])
-
- rand = Math.floor((Math.random() * (characters.length)));
- characterChange(characters[rand])
-
-}
diff --git a/javascript/start_screen.js~ b/javascript/start_screen.js~
deleted file mode 100644
index 9775d0c..0000000
--- a/javascript/start_screen.js~
+++ /dev/null
@@ -1,29 +0,0 @@
-// show the start screen
-
-function showStartScreen() {
- layerNamed('startscreen').style.display = 'inline'; // none = hide layer
-
-}
-
-// start the game
-
-function startGame() {
- // this must be configured one mousedown event in the start screen
- layerNamed('startscreen').style.display = 'none'; // none = hide layer
- startFlapping('bird');
- startMovingBackgound('background', -7);
- startMovingBackgound('cactus', -7);
- startMovingBackgound('DayAndNight', -20);
- startMovingBackgound('SunAndMoon', 1);
- startMovingBackgound('Gotham', -7);
- startMovingBackgound('Gotham_obstacles', -7);
- startMovingBackgound('space', -7);
- startMovingBackgound('space_rocket', -7);
- startMovingBackgound('Snow', -7);
- startMovingBackgound('Gifts', -7);
- startMovingBackgound('Sea', -7);
- startMovingBackgound('fishinghook', -7);
- scaleToFullscreen();
-
-
-}
diff --git a/javascript/v2/main.js b/javascript/v2/main.js
new file mode 100644
index 0000000..670de97
--- /dev/null
+++ b/javascript/v2/main.js
@@ -0,0 +1,22 @@
+// This script contains some functions that will be used throughout the game
+
+var backgrounds = document.getElementsByClassName("background"); // = array
+
+function backgroundChange(background) {
+ for(var i = 0; i < backgrounds.length; i++) {
+ backgrounds[i].style.display = "none";
+ }
+ document.getElementById(background).style.display = "inherit";
+}
+
+function hide_layer(layer) {
+ if(document.getElementById(layer)){
+ document.getElementById(layer).style.display = "none";
+ }
+}
+
+function show_layer(layer) {
+ if(document.getElementById(layer)){
+ document.getElementById(layer).style.display = "inherit";
+ }
+}
diff --git a/layers/environment/DayAndNight.svg b/layers/environment/DayAndNight.svg
index bc50c4c..b14bd53 100644
--- a/layers/environment/DayAndNight.svg
+++ b/layers/environment/DayAndNight.svg
@@ -1,5 +1,5 @@
-
+