![]() ![]() Public void touchControlPanel() // Detect if touching control panel HealthPoints += 100 // adds 100 healthPoint If(gr = 0) // Only takes effect if variable gr equals 0 If (getOneIntersectingObject(Captive2.class) != null) // If Captive2 is intersecting with Subject003 Public void touchInfectedDormous() // Detect if touching Captive2 tWorld(new SpaceShipLevel2(poweredUp, speed, reload)) // Change level to SpaceShipLevel2 true tWorld(new SpaceShipLevel2(poweredUp, speed, reload)) // Change level to SpaceShipLevel2 falseĮlse if (getOneIntersectingObject(Portal.class) != null & poweredUp = true) // If Portal is intersecting with Subject003 and did pick up the captive If (getOneIntersectingObject(Portal.class) != null & poweredUp = false) // If Portal is intersecting with Subject003 and did not pick up Captive Public void touchPortal() // Detect if touching portal ![]() GetWorld().removeObject(getOneIntersectingObject(GoblinBullet.class)) // Remove the GoblinBullet HealthPoints -= 100 // Reduce healthPoints by 1 If(getOneIntersectingObject(GoblinBullet.class) != null) // If GoblinBullet is intersecting with Subject003 Public void damageTaken() // Detect if damage has been taken tWorld(new GameOver()) // Set world image to GameOver If(healthPoints <= 0) // If healthPoints fall below 1 HealthPoints = healthPoints // Detect healthPoints Public void killed() // When health falls below 1 GetWorld().removeObject(Captive) // Remove Captive PoweredUp = true // Whether or not Subject003 has picked up the captive SpaceShipLevel1 no = (SpaceShipLevel1) getWorld() // Get information from SpaceShipLevel1 world class If(Captive != null) // If Captive is detected Public void touchCaptive() // Receive buff if captive is touchedĪctor Captive = getOneIntersectingObject(Captive.class) // Detect if Captive is intersecting with Subject003 If (getOneIntersectingObject(Wall.class) != null) // Detect if intersecting with Wall SetLocation(x,y) // Set location to X and Y If (getOneIntersectingObject(Wall2.class) != null) // Detect if intersecting with Wall2 Public void collision() // Collide with walls SetRotation(0) // Reset image to original position SetRotation(-90) // Rotate image 90 degrees to the left SetRotation(90) // Rotate image 90 degrees to the right SetRotation(180) // Rotate image by 180 degrees to the right If(Greenfoot.isKeyDown("down")) // Detect if down key is pressed Private void rotateImage() // Rotate Subject003 in the direction of arrow keys pressed ![]() Reload- // Decrease reload by 1 every act aySound("AWP.mp3") // Play sound whenever mouse is clicked and reload equals 0 Reload = 80 - abc // Reload resets to 80 every time mouse is clicked GetWorld().addObject(new DormousBullet(getRotation()),getX(),getY()) // Adds a new bullet object when moused is clicked and reload equals 0 If(reload <= 0) // When reload is 0, a bullet can be fired If(Greenfoot.mouseClicked(null)) // Detect if the mouse is clicked SetLocation(getX() + speed, getY()) // Increase position on the X axis to move right If(Greenfoot.isKeyDown("right")) // Check if right arrow key is pressed SetLocation(getX() - speed, getY()) // Decrease position on the X axis to move left If(Greenfoot.isKeyDown("left")) // Check if left arrow key is pressed SetLocation(getX(), getY() + speed) // Increase position on Y axis to move downwards ![]() If(Greenfoot.isKeyDown("down")) // Check if down arrow key is pressed SetLocation(getX(), getY() - speed) // Decrease position on Y axis to move upwards If(Greenfoot.isKeyDown("up")) // Check if up arrow key is pressed Private void checkKeys() // Moves Subject003 in the direction of the arrow keys pressed. TouchInfectedDormous() // Receive health buff when Captive2 is touchedĬollectCheese() // Increase the score by 25 when cheese is collected TouchControlPanel() // Detect if intersecting with control panel Killed() // Detect if health falls below 1 TouchPortal() // Send to level 2 when touched TouchCaptive() // Receive movement speed and firerate buff when Captive is touched RotateImage() // Rotate the image when the correct keys are pressed Reload = newReload // Keep new increased reloadĬheckKeys() // Check which keys are pressed and move in the appropriate direction Speed = newSpeed // Keep new increased speed If(powerMeUp = true) // If Subject003 has picked up the powerup Public Subject003(boolean powerMeUp, int newSpeed, int newReload) // When Subject003 has picked up the captive Public Subject003() // When Subject003 hasn't picked up the Captive Public boolean poweredUp = false // Default setting for poweredUp Private int healthPoints = 1 // healthPoints variable Public class Subject003 extends Characters Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |