![]() ![]() The weird thing is I copied this of an other programm I wrote and there it works without a problem. I gett the Error that it doesn't find the symbol and asks if I mean act(). I dont understand why add() doesn't work. Here i try to add an integer to an Counter. Public void addwürfelanzahl(int würfelanzahl) Create a new world with 600x400 cells with a cell size of 1x1 pixels. ![]() * Constructor for objects of class MyWorld. Greenfoot.getRando mNumber(4) Returns a random number. Greenfoot.getRan domNumber(int limit) Return a random number between 0 (inclusive) and limit (exclusive). Plays the sound le named pop.wav if it is located in the sounds folder created for the Scenario. * Write a description of class MyWorld here. aySound (pop.wav) Supported le types: AIFF, AU and WAV. JOptionPane.Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and If(scoreCounter.getValue() < highScoreCounter.getValue()) Public void act()//makes one virus spawn in a random location for every 100 calls of the act methodĪddObject(new Virus(), Greenfoot.getRandomNumber(680) + 100, Greenfoot.getRandomNumber(710) + 70 ) And of course as always after watching: Fire up Greenfoot, and get coding yourself Download video Oh, and one more thing: I am showing how to implement a score counter here, because several people have asked me how to do that. tValue(ORIGINAL_BEST_TIME) īestTimeHolder = ORIGINAL_BEST_TIME_HOLDER HighScoreCounter = new Counter("Best Time: " + bestTimeHolder + ": ") 3 How i i make my code so if i touch an actor by my controlled actor my score goes up by 1. ScoreCounter = new Counter(player1.getName() + "'s Time: ") \nGood luck!") ĪddObject(new Key(), Greenfoot.getRandomNumber(680) + 100, Greenfoot.getRandomNumber(710) + 70 ) \nViruses will try to attack you but I have equipped you with weapons that will aid you on your quest. JOptionPane.showMessageDialog(null, "Nice to meet you" + " " + inputstr + "! \nI am sorry to tell you this but you are trapped in my system and the only way to get out is to collect the 9 keys in this world. ![]() String inputstr = JOptionPane.showInputDialog("Hello, thank you for playing 9 keys.\n What is your Name?") You can then (later when you need it) get all scores from all levels to display them. It displays and adjusts only the score which represents the current levels score. One would be to use one counter object for all worlds and use an array for the score. \n Be Careful!!! Bombs will destroy everything in range including keys and yourself") this is my code for my counter class, if this helps. JOptionPane.showMessageDialog(null, "Instructions: \n \n Arrow Keys: Movement \n Q Key: fire arrow \n W Key: drop bomb \n Spacebar: pick up key \n Pick up all 9 keys to win. The player and the original virus start in the same spot but the keys are spawned in random locations which makes the game different every time. Public void populateWorld()//creates the player, all of the keys, and one virus. If it is, you can just pass the score), you pass the score like this: //Instead of W, place the name of your world W w (W) getWorld () tWorld (new GameOver (w.counter1.getScore ())) Then you only need to change the. Create a new world with 600x400 cells with a cell size of 1x1 pixels. Then, when you set the new world (in case that this last piece of code is not inside your counter class. Ask the participants to add a new actor called Counter. Public GameWorld1()//construcotr sets the spawnCounter to 100, populates the world, and starts the game Score is a fun part of developing, designing and testing a game but this requires quite a bit. * Constructor for objects of class GameWorld. Pretty much when the bullet hits the asteroid and the checkCollision method called upon I need the counter to go up. When I do what I think would work I get some message similiar to: non static method cannot be referenced from a static context. Public static final String ORIGINAL_BEST_TIME_HOLDER = "Nobody" So Ive tried making the Bullet a subclass of Counter and vise versa. In Greenfoot, the environment is represented by the World class, and objects that interact in the environment are represented by the Actor class. Public static final int ORIGINAL_BEST_TIME = 36000 Basic game elements All games have an environment in which the game takes place and objects interact. Private int spawnCounter //the rate at which enemies spawn in the world. Public class GameWorld1 extends World//Class heading In the future I will have different levels which are the other GameWorlds. * At the moment this is the only gameworld class that has code in it. This class represents the world in which the game takes place. 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 |