Question: Can I get some help with coding a skeleton program? Game World Objects For now, assume that the game world size is fixed and covers

Can I get some help with coding a skeleton program?

Game World Objects

For now, assume that the game world size is fixed and covers 1000 (width) x 1000 (height) area (although we are going to change this later). The origin of the world (location (0,0)) is the lower left hand corner. The game world contains a collection which aggregates objects of abstract type GameObject. There are two kinds of abstract game objects called: fixed objects of type Fixed with fixed locations (which are fixed in place) and moveable objects of type Movable with changeable locations (which can move or be moved about the world). For this first version of the game there are two concrete types that fixed objects are instantiated from which are called: Base and EnergyStation; and there are two concrete types that moveable objects are instantiated from which are called: Cyborg and Drone. Later we may add other kinds of game objects (both fixed kinds and moveable kinds) as well. The various game objects have attributes (fields) and behaviors (methods) as defined below. These definitions are requirements which must be properly implemented in your program.

All game objects have an integer attribute size. All game objects provide the ability for external code to obtain their size. However, they do not provide the ability to have their size changed once it is created. As will be specified in the later assignments, each type of game object has a different shape which can be bounded by a square. The size attribute provides the length of this bounding square. All bases and all cyborgs have the same size (chosen by you), assigned when they are created (e.g, size of all bases can be 10 and size of all cyborgs can be 40). Sizes of the rest of the game objects are chosen randomly when created, and constrained to a reasonable positive integer value (e.g., between 10 to 50). For instance, size of one of the energy station may be 15 while size of another energy station may be 20.

All game objects have a location, defined by Point built-in class of CN1 (which resides under com.codename1.charts.models and uses float values), which is constituted from non-negative values X and Y which initially should be in the range 0.0 to 1000.0. The point (X,Y) is the center of the object. Hence, initial locations of all game objects should always be set to values such that the objects centers are contained in the world. All game objects provide the ability for external code to obtain their location. By default, game objects provide the ability to have their location changed, unless it is explicitly stated that a certain type of game object has a location which cannot be changed once it is created. Except bases and cyborgs, initial locations of all the game objects should be assigned randomly when created. All game objects have a color, defined by a int value (use static rgb() method of CN1s built-in ColorUtil class to generate colors). All objects of the same class have the same color (chosen by you), assigned when the object is created (e.g, bases could be blue, cyborgs could be red, energy stations can be green). All game objects provide the ability for external code to obtain their color. By default, game objects provide the ability to have their color changed, unless it is explicitly stated that a certain type of game object has a color which cannot be changed once it is created. Bases are fixed game objects that have attribute sequenceNumber. Each base is a numbered marker that acts as a waypoint on the track; following the track is accomplished by moving over on top of bases in sequential order. Bases are not allowed to change color once they are created. All bases should be assigned to locations chosen by you, when they are created. Energy stations are fixed game objects that have an attribute capacity (amount of energy an energy station contains). The initial capacity of the energy station is proportional to its size. If the player cyborg is running low on energy, it must go to an energy station that is not empty before it runs out of energy; otherwise it cannot move. All fixed game objects are not allowed to change location once they are created. Moveable game objects have integer attributes heading and speed. Telling a moveable object to move() causes the object to update its location based on its current heading and speed. The movable game objects move simultaneously according to their individual speed and heading. Heading is specified by a compass angle in degrees: 0 means heading north (upwards on the screen), 90 means heading east (rightward on the screen), etc. See below for details on updating an movable objects position when its move() method is invoked. Some movable game objects are steerable, meaning that they implement an interface called ISteerable that allows other objects to change their heading (direction of movement)after they have been created. Note that the difference between steerable and moveable is that other objects can request a change in the heading of steerable objects whereas other objects can only request that a movable object update its own location according to its current speed and heading.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!