Java代写:CS335 Snake / Magneto

参考Snake / Magneto游戏,代写一款类似的游戏。

Requirement

In the previous checkpoint you described an idea and a model for a game or application for the Android platform.

For your second project checkpoint you need to create code for the Model, View, and Controller classes (where __ stands for your game name) for your game/app choice. The expectation in this checkpoint is that your View/Controller may be very basic or non-functional. Please focus on coding your Model and writing some tests for your model if you are working on a Game. Please focus on coding your Model and pulling data from the Internet / file resources if you are working on an Application.

For full credit on the checkpoint we will expect all components of your model to be represented in some class and we will expect some of the mutation to work correctly (such as onTick / onUpdate or player / user actions).

If You Are Creating A Game

Generally follow the Snake / Magneto sample projects. You should create a new Android application similar to the tutorial for the SolarModel and then copy into your src folder the gameframework code. Here are the steps I would recommend after that:

  • __Game: Create a class that extends Game where the ___ is the name of your game (i.e. SnakeGame or MagnetoGame or YourGame). Add as properties to your game class all of the objects you listed in your idea sheet (you probably need to create classes for some of them as well).

  • __Action: create a class (or classes) to encapsulate an action that could be made by a player in your game. It should implement Action.

    • Override the public void update(YourGame game) and place code in there that will call mutator methods on YourGame or components of your game to implement the player action.
    • Most likely you will need to add some mutators to different classes in your game model so that your Actions can call these mutators.
  • __Game.onTick OR __Game.onUpdate(float time): For all tick based games you will want to look at the SnakeGame onTick method. For all continuous time based games you will want to look at the MagnetoGame onUpdate method. If your game has any kind of automatic updates over time, this is where the logic should go.

    • You should only override onTick OR onUpdate. If you override onTick you must also override getTickLength() and return something > 0.
    • If different objects in your game have their own tick/update logic, then put the logic in those classes and call an onTick/onUpdate method on each object (passing in your Game instance if necessary).
    • Write tests for your onTick/onUpdate methods.
  • __Tests: make sure to write some tests that show updates/actions working for your game model.

  • __View: Look at MagnetoView and SnakeView for examples. You may even want to copy one of them into your project and modify the code to draw at least some basic shapes to represent things in your Game model. At this point your view can be very basic, but it is helpful for debugging to have something drawn.

  • __Activity: Again, you may want to copy code from MagnetoActivity or SnakeActivity to your own project. You want to have an Activity that when created by Android makes an instance of your Game, an instance of your View and sets the content view.

  • __Controller: Optional for this checkpoint, but if you are able to you can setup the ModelUpdateController to update your game according to time and a TouchController to create Actions and tell your game to perform those actions.

Export and submit your checkpoint 2 project to Sakai as a .zip archive.

If You Are Creating An Application

Generally follow the SampleWeather project (you can also look at some of the user interface and model code from the MadlibsActivity). You should create a new Android application similar to the first Android tutorial (create one activity for now). Here are the steps I would recommend after that:

  • activity_?.xml: create a basic view using the graphical interface / xml to show various things in your model. You can create multiple screens by using the Fragment framework (in Android Studio, right click app then choose New -> Fragment -> blank). Edit each one of your views in the graphical interface / xml
  • __Activity: similar to the SampleWeather project, create your model objects and a wrapper view class (similar to WeatherView).
  • RemoteFetch: if you are working with a data source that you need to retrieve information from, consult their APIs and see if you can copy the RemoteFetch class from the SampleWeather project and adapt it for your needs.
  • Local data: if you are loading resources (such as text files), see the MadlibsActivity to see how you can load a file from the /assets folder into your application. If you don’t have the/assets folder in your project already, right click app and choose New->Folder->Assets Folder.
  • tests: It is a little more difficult to test an app with JUnit tests, so I would suggest keeping your checkpoint fairly simple for now and provide one main view that auto-populates data from a source
  • __Controller: not necessary at this point, but if you want to test some user input you can easily make menu options or a simple button that will trigger some update to your model.

Export and submit your checkpoint 2 project to Sakai as a .zip archive.