web | 代写scala | java | oop | project | html代做 – Game Systems

Game Systems

web | 代写scala | java | oop | project | html代做 – 本题是一个利用web进行练习的代做, 对web的流程进行训练解析, 涉及了web/scala/java/oop/html等代写方面, 这是值得参考的project代写的题目

java代写 代写java

RICHARD MCCREADIE

MSC IT+ TEAM PROJECTS

Your Role in the Project
  • We are not asking you to build the full stack of services
needed to construct the game
  • Instead, we have pre-built the front-end for you (which will be

######## provided as a java code project to you in Project Week 2)

  • Your goal is to build the back-end data structures and
game logic to enable the game to be played correctly
Game Systems
  • To make an asynchronous browser game function, we
actually need a range of technologies:
Java Virtual Machine
 web Server

SourcesJava Sources scala html Files JavaScriptFiles (e.g. images)Assets

Framework
H J
Game Systems
  • To make an asynchronous browser game function, we
actually need a range of technologies:
Java Virtual Machine
Web Server

SourcesJava SourcesScala HTML Files JavaScriptFiles (e.g. images)Assets

Framework
J
Game Controller
Game Actor
Your Code initialize
drawTile
Events and Commands
  • The core of what you will be doing is building the game
logic in Java that:
  • Receives events from the users browser
    • Either reports of user interactions with the interface or notifications of when playing animations start and end
  • Issues commands for how to change what is rendered in the user

######## interface

  • E.g. render a unit, change a life total, etc.
Messaging
  • The core concept that you need to understand is messaging
  • The Game Actor is a Java class that acts as a central communication point between your code and the users web browser – A processMessage() method will be called in this class each time an event is received. – You can createand send a message (in the form of a JSON object) to the users browser, and if its format matches one of the supported commands, the interface will be updated accordingly

Your Code Game Actor

cardClicked
swapCardTexture< cardClicked >
swapCardTexture(Highlight)

Basic Objects

Base Classes
  • As part of the pre-provided Java template you will be given

####### five base classes that you can (an should extend) as needed

  • These classes provide some basic functionality that is needed by the user interface for visualisation
  • Base Classes:
  • Tile
  • Unit
  • Player
  • Card
  • EffectAnimation
Tile
  • List tileTextures; // urls of different tile textures
  • int xpos; // x (horizontal) pixel position of the tile
  • int ypos; // y (vertical) pixel position of the tile
  • int width; // Pixel width of the tile
  • int height; // Pixel height of the tile
  • int tilex; // x (horizontal) index in the board grid (range 1-9)
  • int tiley; // y (vertical) index in the board grid (range 1-5)
Unit
  • int id; // a unique id for the unit
  • String animation; // animation to play [idle,death,attack,move]
  • Position position; // contains board position data
  • UnitAnimationSet animations; // contains animation data
  • ImageCorrection correction; // contains pixel position correction data
Player
  • int health; // Current player health
  • int mana; // Current player mana
Card
  • int id; // a unique id for the card
  • List cardTextures; // urls of different versions of the card image
EffectAnimation
  • List animationTextures; // urls of different frames of the animation
  • ImageCorrection correction; // contains pixel position correction data
  • int fps; // frames per section to run the animation

Commands

drawTile
  • You can consider the contents of the users browser window a canvas that can be drawn upon. drawTilewill draw the image of a board tile on the board.This command takes as input a Tile object and a visualisation mode (an integer) that specifies which version of the tile to render (each tile has multiple versions, e.g. normal vs. highlighted). This command can be used multiple times to change the visualisation mode for a tile.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", drawTile");
returnMessage.put(tile", <JSON TileObject AsString>);
returnMessage.put(mode", <visualisation mode>);
out.tell(returnMessage, out); }
drawUnit
  • drawUnitwill draw the sprite for a unit (a picture of that unit with its attack and health values) on the board. This command takes as input a target Tile (a square of the main game grid) to place the units sprite upon, and the instance of the Unit (which holds the needed information about how to draw that unit).
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", drawUnit");
returnMessage.put(unit", <JSON UnitObject AsString>);
returnMessage.put(tile", <JSON TileObject AsString>);
out.tell(returnMessage, out); }
setUnitAttack/setUnitHealth
  • These commands change the visualised attack/health values just under a units sprite to a value between 0 and 20. The command takes in a unit instance. The associated values are read from the unit object.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", setUnitAttack");
returnMessage.put(unit", <JSON UnitObject AsString>);
out.tell(returnMessage, out); }
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", setUnitHealth");
returnMessage.put(unit", <JSON UnitObject AsString>);
out.tell(returnMessage, out); }
moveUnitToTile
  • This command moves a unit sprite from one tile to another. It takes in the units object and the target Tile. Note that this command will start the movement, it may take multiple seconds for the movement to complete.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", moveUnitToTile");
returnMessage.put(unit", <JSON UnitObject AsString>);
returnMessage.put(tile", <JSON TileObject AsString>);
out.tell(returnMessage, out); }
playUnitAnimation
  • This command makes a unit play an animation. Each unit has a set of animation frames stored in an array. The play animation command takes as input the index of the first and last frame to play in the animation, along with whether to l oop the animation continually.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", playUnitAnimation");
returnMessage.put(unit", <JSON UnitObject AsString>);
returnMessage.put(startFrame", <index of start frame>);
returnMessage.put(endFrame", <index of end frame>);
returnMessage.put(loop", <Boolean, do we loop continually?>);
out.tell(returnMessage, out); }
deleteUnit
  • This will delete a unit instance from the board. It takes as input the unit object of the unit.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", deleteUnit");
returnMessage.put(unit", <JSON UnitObject AsString>);
out.tell(returnMessage, out); }
setPlayer1Health/setPlayer2Health
  • These commands change the visualised health values in the players information card to a value between 0 and 20. The command takes in a basic player instance. The associated values are read from the basic player object.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", setPlayer1Health");
returnMessage.put(player", <JSON PlayerObject AsString>);
out.tell(returnMessage, out); }
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", setPlayer2Health");
returnMessage.put(player", <JSON PlayerObject AsString>);
out.tell(returnMessage, out); }
setPlayer1Mana/setPlayer2Mana
  • These commands change the visualised resource/mana values in the players information card to a value between 0 and 9. The command takes in a basic player instance. The associated values are read from the basic player object.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", setPlayer1Mana");
returnMessage.put(player", <JSON PlayerObject AsString>);
out.tell(returnMessage, out); }
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", setPlayer2Mana");
returnMessage.put(player", <JSON PlayerObject AsString>);
out.tell(returnMessage, out); }
drawCard
  • This command renders a card in the players hand. It takes as input a hand position (a value between 1-6), a Card (which is an object containing basic information needed to visualise that card) and a visualisation mode (similarly to a tile). This command can be issued multiple times to change the visualisation mode of a card.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", drawCard");
returnMessage.put(position", <index of the hand position>);
returnMessage.put(card", <JSON CardObject AsString>);
returnMessage.put(mode", <visualisation mode>);
out.tell(returnMessage, out); }
deleteCard
  • This command deletes a card in the players hand. It takes as input a hand position (a value between 1-6).
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put("messagetype", deleteCard");
returnMessage.put(position", <index of the hand position>);
out.tell(returnMessage, out); }
playEffectAnimation
  • Plays a specified EffectAnimation(such as an explosion) centred on a particular Tile. It takes as input an EffectAnimation(an object with information about rendering the effect) and a target Tile.
{ ObjectNode returnMessage = Json. newObject();
returnMessage.put(effect", <JSON EffectAnimationObject AsString>);
returnMessage.put(tile", <JSON TileObject AsString>);
out.tell(returnMessage, out); }

Events

heartbeat
  • In the users browser, the game is running in an infinite loop, where there is around a 1 second delay between each loop. Its during each loop that the UI acts on the commands that have been sent to it. A heartbeat event is fired at the end of each loop iteration. As with all events this is received by the Game Actor, which you can use to trigger game logic.
{
String messageType = heartbeat
}
unitMoving/unitStopped
  • Indicates that a unit instance has started a move or has stopped moving. The event reports the unique id of the unit.
{
messageType = unitMoving
id = <unit id>
}
{
messageType = unitStopped
id = <unit id>
}
tile|card|endturn|other Clicked
  • Indicates that the user has clicked an object on the game canvas. This can either be a tile, card, the end turn button or somewhere else. The information included will vary depending on what was clicked.
{
messageType = tileClicked
tilex = <x index of the tile>
tiley = <y index of the tile>
}
{
messageType = cardClicked
position = <hand index position [1-6]>
}
{
messageType = endTurnClicked
}
{
messageType = otherClicked
}