![]() No other classes may be modified or created. * Write a description of class Creepers here.Hi, I need help with my greeps code for my class ![]() If you want, I can show you the basic code to contain the healthbar within an actor class or even upload a simple sample demo. The external healthbar codes should be totally contained within the Greeps class (this includes the creation, addition to world, changing value of, moving and removing of the healthbar) so, there is no need for a parameter for that, as well. To summarize, it appears that the only parameter you may need is the one for initial health points. Int lv: this value should be stored in your world class and made accessible to other classes from there.Ĭounter lives: I am unsure if your greeps has lives or not I would think that once their health is depleted, they are removed permanently from the world I do not know of any games where an actor other than the main character has more than one life. Int speed: I do not think that this value should come in from outside the class better might be to use a static int field for the default speed value of new greeps and set the instance speed field for the greep to its value when created (it can still be changed from outside the class before creating new greeps) Int hp: I can understand this one the subclasses can supply the initial health values though it The following is the parameter list that you show in your Greeps class constructor: I do not know exactly what changes have been made to the Greeps class at this point but, I felt I should mention this: Remove the 'healthbar' field from the world class and then within the 'spawn' method, create the healthbar objects first, add them into the world and then create the greep object and add it into the world passing the healthbar just created.Īlso, I still getting the same error, but happens before anything gets created in theĪt (Simulation.java:574)Īt (Simulation.java:509)Īt (Simulation.java:215)Īt (Simulation.java:205) The problem is that you are passing all the greeps the same non-existent healthbar (null) that is held in the 'healthbar' field (nothing is ever set to the field) and then adding different healthbars into the world (supposedly for each greep). You do have only one lives and one money counter - but, you are creating a healthbar for each greep spawned. One of each is needed for each Greeps object if they are to have their own values for these states.Sorry - I was not thinking clear (or did not see the whole picture). I ask these questions because you currently have only ONE healthbar and ONE lives counter and ONE money counter created in the world. ![]() (2) Are each Greeps object (regardless of subclass created from) to have a healthbar and a lives counter and a money counter? (1) How many of each subclass of Greeps will you be creating? Hb.fillRect(1,1,health*healthPerPixel,height) ĭanpost wrote.Let me ask you a few questions, here. SetImage(new GreenfootImage(width+2,height+2)) * Write a description of class HealthBar here. GetWorld().addObject(new MainMenuButton(),300,225) Int theDistance = (int)(Math.hypot(WayX - getX(), WayY - getY())) ![]() * Sets the speed of the Greeps and determins when to move onto the next waypoint Heavy heavy = new Heavy(level,lives,healthbar) ĪddObject(new HealthBar(),heavy.getX(),heavy.getY()) Medium medium = new Medium(level,lives, healthbar) ĪddObject(new HealthBar(),medium.getX(),medium.getY()) Small small = new Small(level,lives,healthbar) ĪddObject(new HealthBar(),small.getX(),small.getY()) Create a new world with 600x425 cells with a cell size of 2x2 pixels. * Constructor for objects of class Stage1. * Write a description of class Stage1 here. Import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |