diff --git a/Astroid Base.png b/Astroid Base.png new file mode 100644 index 0000000..993bc39 Binary files /dev/null and b/Astroid Base.png differ diff --git a/README.md b/README.md deleted file mode 100644 index 93d71f9..0000000 --- a/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Co-Op 2018 - -* Rutvi! -* Janardan! -* Yehchan! - -Starter repository for co-op student work, 2018. - -**GitHub Introduction starring @waharnum!** diff --git a/alien.png b/alien.png new file mode 100644 index 0000000..7540580 Binary files /dev/null and b/alien.png differ diff --git a/copper.png b/copper.png new file mode 100644 index 0000000..4e142bd Binary files /dev/null and b/copper.png differ diff --git a/dropDown.png b/dropDown.png new file mode 100644 index 0000000..9972212 Binary files /dev/null and b/dropDown.png differ diff --git a/fuel.png b/fuel.png new file mode 100644 index 0000000..b2df082 Binary files /dev/null and b/fuel.png differ diff --git a/iron.png b/iron.png new file mode 100644 index 0000000..f621d06 Binary files /dev/null and b/iron.png differ diff --git a/loadingImagesRebuildingShip.js b/loadingImagesRebuildingShip.js new file mode 100644 index 0000000..fd7965f --- /dev/null +++ b/loadingImagesRebuildingShip.js @@ -0,0 +1,24 @@ +function loadImage() { + backgroundAsteroid = this.document.getElementById("background"); + alienAvatar = this.document.getElementById("alien"); + speechBubble = this.document.getElementById("speechBubble"); + yesButton = this.document.getElementById("yes"); + noButton = this.document.getElementById("no"); + scannedNoButton = this.document.getElementById("scannedNo"); + scannedYesButton = this.document.getElementById("scannedYes"); + dropDownMenu = this.document.getElementById("menu"); + scannedMenu = this.document.getElementById("scannedMenu"); + dropDown = this.document.getElementById ("dropDown"); + plus = this.document.getElementById ("plus"); + minus = this.document.getElementById("minus"); + scannedPlus = this.document.getElementById ("scannedPlus"); + scannedMinus = this.document.getElementById ("scannedMinus"); +} + +//loading resources +function loadResources() { + fuel = this.document.getElementById("fuel"); + copper = this.document.getElementById("copper"); + iron = this.document.getElementById("iron"); + stars = this.document.getElementById("stars"); +} \ No newline at end of file diff --git a/menu.png b/menu.png new file mode 100644 index 0000000..370f9c2 Binary files /dev/null and b/menu.png differ diff --git a/minus.png b/minus.png new file mode 100644 index 0000000..8e9bf1a Binary files /dev/null and b/minus.png differ diff --git a/no.png b/no.png new file mode 100644 index 0000000..7cd2a42 Binary files /dev/null and b/no.png differ diff --git a/onKeyUp.js b/onKeyUp.js new file mode 100644 index 0000000..c0a8ddb --- /dev/null +++ b/onKeyUp.js @@ -0,0 +1,45 @@ +window.onkeyup = function(e) { //takes the spacebar as a key input + if (e.key === " ") { + if(stage === "rebuildingShip"){ + if(rebuildingShipScanningStage === 2 && pressedButton === false){ + if(imageSelection === 0){ + if(scanTimes - 0.25 >= 0.25){ + scanTimes -= 0.25; + } + pressedButton = true; + } + if(imageSelection === 1){ + if(scanTimes + 0.25 <= 3){ + scanTimes += 0.25; + } + pressedButton = true; + } + if(imageSelection === 2){ + rebuildingShipScanningStage = 1; + pressedButton = true; + imageSelection = 3; + speedCounter = 0; + } + speedLimit = 1500/ scanSpeed / scanTimes; + } + if(rebuildingShipScanningStage === 1 && pressedButton === false){ + if(imageSelection === 0){ + stage = "map"; + } + if(imageSelection === 1){ + stage = "map"; + } + if(imageSelection === 2){ + rebuildingShipScanningStage = 2; + imageSelection = 3; + speedCounter = 0; + } + } + } + else if(stage === "map"){ + stage = "rebuildingShip"; + imageSelection = 0; + speedCounter = 0; + } + } +} \ No newline at end of file diff --git a/plus.png b/plus.png new file mode 100644 index 0000000..f35aee5 Binary files /dev/null and b/plus.png differ diff --git a/printingRebuildShip.js b/printingRebuildShip.js new file mode 100644 index 0000000..af6f804 --- /dev/null +++ b/printingRebuildShip.js @@ -0,0 +1,39 @@ +function printNumOfResources (){ + //prints the number of items the + ctx.fillText(randAmount[0], (xposOfResource + 80), 260); + if (randNum === 2 || randNum === 3) { + ctx.fillText(randAmount[1], (xposOfResource2 + 80), 260); + } + if (randNum === 3) { + ctx.fillText(randAmount[2], (xposOfResource3 + 80), 260); + } + for(var i = 0; i < randNum; i++){ + if(resourceUsed[i] === 1){ + ctx.drawImage(copper, xposOfResource, 210 , 100, 100); + } + if(resourceUsed[i] === 2){ + ctx.drawImage(fuel, xposOfResource2, 190, 100, 100); + } + if(resourceUsed[i] === 3){ + ctx.drawImage(iron, xposOfResource3, 200, 100, 100); + } + } +} +//function prints the number of resources the player currently has left +function printResources() { + ctx.drawImage(fuel, 1000, -10, 100, 100); + ctx.drawImage(copper, 750, 10, 100, 100); + ctx.drawImage(stars, 400, -10, 100, 100); + ctx.drawImage(iron, 50, -10, 100, 100); +} +//background plus alien thats always printed out +function printGame(){ + ctx.drawImage(backgroundAsteroid, 0, 0, 1280, 720); //draws the background + printResources(); //print the resouces onto the screen + //prints image of the alien that is asking for the resources, and a speech bubble + ctx.drawImage(alienAvatar, 800, 350, 200, 200); + ctx.drawImage(speechBubble, 750, 200, 500, 150); + ctx.drawImage(yesButton, 50, 150, 200, 150); + ctx.drawImage(noButton, 50, 350, 200, 150); + ctx.drawImage (menu, 1220, 10, 50, 50); +} \ No newline at end of file diff --git a/randomMaterialsNeededRebuildingShip.js b/randomMaterialsNeededRebuildingShip.js new file mode 100644 index 0000000..ad0b939 --- /dev/null +++ b/randomMaterialsNeededRebuildingShip.js @@ -0,0 +1,11 @@ +var randNum = Math.floor(Math.random() * 3) + 1; //a number that determines how many items the alien will ask for +//a random numeber generator for the aliens request +//stores the number of resrouces the alien asks for each category +var randAmount = [0, 0, 0]; //number of each item (will be between 1 - 7) +var resourceUsed = [1 , 2, 3]; + +function randResources (){ + for(var i = 0; i < randNum; i++){ + randAmount[i] = Math.floor(Math.random() * 7) + 1; + } +} \ No newline at end of file diff --git a/rebuildShip.html b/rebuildShip.html new file mode 100644 index 0000000..2abbccd --- /dev/null +++ b/rebuildShip.html @@ -0,0 +1,46 @@ + + +
+ + +