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 Image.Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) GetWorld().addObject(new ScoreBoard(), 400, 400) * Act - do whatever the Goldasteroid wants to do. * Write a description of class Goldastroid here. GetWorld().addObject(new Alienship(), Greenfoot.getRandomNumber(700), Greenfoot.getRandomNumber(700)) * Act - do whatever the Alienship wants to do. * Write a description of class Alienship here. * Laser will destroy Alienship if it hits them. * Write a description of class Laser here. GetWorld().addObject(new Goldastroid(), Greenfoot.getRandomNumber(700), Greenfoot.getRandomNumber(700)) * If so then pick it up and add 50 points to score. * Check to see if we are touching a Goldastroid. GetWorld().addObject (laser, getX(), getY()) Laser laser = new Laser (getMovement().copy(), getRotation()) * Checks for a pressed key, if this is true it will exeacute an action. * the 'Act' or 'Run' button gets pressed in the environment. * Act - do whatever the Redship wants to do. Private static final int gunReloadTime = 15 * Write a description of class Redship here. Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) SetImage(new GreenfootImage(stringLength, 16)) Private static final Color textColor = new Color(255, 180, 150) * Counter that displays a text and number. Image.drawString(prefix + score, 60, 200) GreenfootImage image = new GreenfootImage(WIDTH, HEIGHT) Private void makeImage(String title, String prefix, int score) MakeImage("Game Over", "Score: ", score) * Create a score board for the final result. * Create a score board with dummy result for testing. Public static final float FONT_SIZE = 48.0f * The ScoreBoard is used to display results on the screen. Import greenfoot.* // (World, Actor, GreenfootImage, and Greenfoot) I am trying to make it when I pick up a Goldasteroid the score will add up 5 and if I destroy an Alienship the score will add 10 points here is what I have: I need help on trying to get my score counter to work I have looked at many other forums for this and still nothing.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |