![]() ![]() After using them for a while, you will be surprised that you found them so difficult at first.ġ13 7. (The counter needs adding to the World in the same way the Actors were added previously. The more practice you get, the easier it becomes. Understanding lists and loops is initially quite difficult, but very important in programming, so you should carefully review these aspects of your code if you are not yet comfortable in using them. ![]() */ private void createStars(int number) else // Splitting an Asteroid is worth 10 points int r = getMovement().getDirection() + Greenfoot.getRandomNumber(45) double l = getMovement().getLength() Vector speed1 = new Vector(r + 60, l * 1.2) Vector speed2 = new Vector(r - 60, l * 1.2) Asteroid a1 = new Asteroid(size/2, speed1) Asteroid a2 = new Asteroid(size/2, speed2) getWorld().addObject(a1, getX(), getY()) getWorld().addObject(a2, getX(), getY()) a1.move() a2.move() untScore(10) ġ12 7.11 Summary of Programming Techniques A world that does not have a background image assigned will, by default, get an automatically created background image that is filled with plain white.ĩ The Background is Created by These Three StatementsĮxercise 7.6 The Background is Created by These Three Statementsġ0 Code to Create the Background is Commented OutĮxercise 7.7 Code to Create the Background is Commented Outġ2 Exercise 7.8 Draw Oval Draw Rectangle Fill Ovalġ8 Exercise 7.10 /* * Method to create stars. The ScoreBoard, Explosion, and ProtonWave classes, which we can see in the class diagram, do not seem to feature in the scenario.Ĥ Exercise 7.2 Controls for the Rocket Collision Logic Explosion LogicĮxercise 7.3 Spacebar is used to fire a bulletĦ Creates the Explosion Visual and makes and Explosion SoundĮxercise 7.4 Creates the Explosion Visual and makes and Explosion Soundħ The visual is Present, But It Does Not Do AnythingĮxercise 7.5 The visual is Present, But It Does Not Do AnythingĨ 7.2 Painting Stars The Asteroid Scenario does not use an image file for the background. The game never ends, and a final score is never displayed. It flies straight through it, instead of damaging the rocket. Nothing happens when an asteroid collides with the rocket. It cannot be turned, nor can it be moved forward. When experimenting with the current scenario, you will notice that some fundamental functionality is missing. Image.1 Chapter 7 - Collision Detection: Asteroids 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. 3 How i i make my code so if i touch an actor by my controlled actor my score goes up by 1. * 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)) some added features (such as a proton wave and a score counter). * If so then pick it up and add 50 points to score. Greenfoot supports the Java Programming Language, so students learn standard object. * 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 |