![]() ![]() 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 This way, the player object moves from one world to the next.Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) In the Level2 class (a subclass of World), you could then have a constructor: tWorld (new Level2(this)) // create new world, install it, and pass myself into it GetWorld().removeActor(this) // leave the current world For example, if a game character wanted to move to Level 2 (a second world), and the character object should really move across, so that state is preserved, you could write (in the player actor): (Other worlds are not in the same plane – they are not to the right or below the current one, they are completely disconnected).Īctors can be transferred into another world just by passing a reference to the actor into the world, and adding it. But they cannot transfer into other worlds this way. Actors can then go out of the screen (becoming invisible to the user) and come back at later stage. No, the ‘bounded’ flag just removes the world size bounds, essentially making worlds infinite size. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |