asteroids模板 游戏 java_greenfoot开发java游戏

In this program assignment, you will implement classes for averyminimalist version of the classic video game calledAsteroids.  While the requirements for this assignment are very basic, you also have the freedom to adapt or expand on the basic ideas presented here in many ways if you would like to customize the game.Note:For simplicity, we will not be implementing the full physics of the originalAsteroidsgame.  Instead, we will use a simplified physics approach that is much simpler to program.  If you're interested in comparing your result here to the original, there are several playable versions ofAsteroidsavailable on-line, includingthis one.In the variant ofAsteroidsyou will implement, there are only three kinds of objects: your ship, the bullets your ship fires, and the asteroids.  All of these objects move in straight lines, although you can steer your ship and control its speed. Structuring Your Solution Be sure you are using Greefoot4Sofia v2.2.1-13 or later for this assignment (to be posted approximately April 2). Your task is to write the four main classes: Ship, Bullet, Asteroid, and Space. You may write additional classes to structure your solution if you desire. Hint: consider consolidating common features of classes into one or more superclasses of your own design. Unlike earlier assignments, here we will use a world with a cell size of 1 pixel by 1 pixel. In Greenfoot, actors by default have a size determined by their image, so the actors in this program will be much larger than a single cell. Actor locations--that is, cell coordinates--will be in pixel sizes here. Actors are drawn so that their image is centered on their location. Also, the getIntersectingObjects() method takes into account the Actor's physical size, not just its location, so it works as you would expect for actors that are larger than a single cell in size. The Space Class The Space class represents the world for your game. It must provide two constructors: a constructor that takes a width and a height, and a default constructor. Both constructors should ensure that the world is created with a cell size of 1 pixel square. For the default constructor, you pick your own default world size--you might start with a size like 500x500 pixels, and then adjust the size larger or smaller so that it looks good on your screen. For the Space image, you can use the backgrounds/space1.jpg image provided in Greenfoot's image library, or you can import another image from a file to customize the look of your game (use the "Import from file..." button when setting the image, and provide a PNG, JPG, or GIF image that you have found on the web or created yourself--even a photo will work). Finally, your Space class should provide a method called populate() method that creates one ship in the center of the world facing north, and creates 5 randomly placed asteroids, each of which has a random speed between 1-5, and a random orientation from 0-359. Write your default constructor so that it calls populate() to set up the world in a ready-to-play configuration. The Asteroid Class The Asteroid class represents the "hazard" in your game. It is simply a rock floating through space. This class must provide a constructor that takes two integer parameters: a speed (in pixels per turn), and a rotation (in degrees). The Asteroid class should provide a method called getSpeed() that returns the asteroid's speed. Note that the Actor class already provides a getter and setter for the object's rotation. For the Asteroid image, you can download and import the image below, or you can import another image from a file to customize the look of your game: The behavior of anAsteroidis simple: it moves ahead on each call toact()the distance specified by its first constructor parameter (its speed).  Remember that theActorclass provides amove(int)method that moves a specified distance forward in the direction the actor is currently facing.There is one extra twist to moving an asteroid--if, after moving the asteroid forward, it is located on any edge of the world, it should "wrap around" to the other side.  In other words, if after moving, the asteroid ends up on the northern edge of space, it should be transported to the corresponding spot on the southern edge, as if it flew off the top edge and re-entered the world on the bottom edge.  Implement the same processing for the left/right edges of the world as well.Finally, if the asteroid collides with a ship or bullet, both the asteroid and the ship should be removed from the world (but asteroids harmlessly pass through each other :-)).The Bullet ClassTheBulletclass represents the shots your ship fires at the asteroids.  It is simply a projectile flying through space.  This class must provide a constructor that takes two integer parameters: a speed (in pixels per turn), and a rotation (in degrees).TheBulletclass should provide a method calledgetSpeed()that returns the asteroid's speed.  Note that theActorclass already provides a getter and setter for the object's rotation.For theBulletimage, you can download and import the image below, or you can import another image from a file to customize the look of your game:专业程序代写 c++程序代写

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值