1 / 20

CS3523 Pacticals

CS3523 Pacticals. Guide. Tools you need. Java IDE (preferably NetBeans) XML (a tiny bit) We may use some other software too. Java. Knowledge of the Java programming language is essential for this course.

Download Presentation

CS3523 Pacticals

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS3523 Pacticals Guide

  2. Tools you need • Java • IDE (preferably NetBeans) • XML (a tiny bit) • We may use some other software too.

  3. Java • Knowledge of the Java programming language is essential for this course. • If you don’t have such knowledge then you had better be prepared to acquire it rapidly, on your own. • Tutorials http://docs.oracle.com/javase/tutorial/ • Documentation http://docs.oracle.com/javase/6/docs/

  4. IDE • Use of an IDE like NetBeans or Eclipse is strongly recommended for manipulating the many files used for particular programs. • I favour NetBeans • http://netbeans.org/

  5. The Dungeon • Practicals use a “dungeon” game of a typical kind to help you learn how to dostuff. • Game is played on a PC • One human player • NPCs are mostly hostile monsters • Player explores dungeon, finds treasure, fights monsters.

  6. CS3523 Game

  7. The Key • Hero is the green circle. • Other creatures are the red circles. • Strength/health potions in blue and green bottles • Gold (in various quantities), keys (associated with particular doors). • Tiles: rooms, doors, flame traps, pits, non-game space (black), Finish (green). • Doors: open (white), closed (grey) • [Run demo.]

  8. The Dungeon World • World model • Tiles: Floor, Door, Flametrap, Pit, Finish • dungeon.model.structure • Treasure: Gold, Potion, Key • dungeon.model.items.treasure • Mobs: Orc, Ogre, Hero • dungeon.model.items.mobs

  9. Dungeon • The dungeon program can get info about tiles, treasure, mob via methods of the gameobject. • Can load/save game to XML file from GUI (or from API)

  10. Dungeon XML file <Game Name="simple"> - <Map> <Tiles> <Vector> <Floor Height="50" Width="50" X="0.0" Y="0.0" /> <Floor Height="10" Width="10" X="-20" Y="0.0" /> </Vector> </Tiles> </Map> - <Creatures> <Vector> - <Orc CurrentEnergy="10" CurrentHealth="10" Gold="20" X="25" Y="25" Behaviour="dungeon.ai.DefaultBehaviour"> - <Attacks> - <Vector> <Smash /> </Vector> </Attacks> - <Inventory> <Vector /> </Inventory> </Orc> </Vector> </Creatures> - <Treasure>- <Vector> <Gold Worth="10" X="23" Y="17" /> <Gold Worth="20" X="5" Y="37" /> <Gold Worth="30" X="42" Y="11" /> <Gold Worth="40" X="45" Y="29" /> <Potion Type="0" X="3" Y="5" /> </Vector></Treasure> </Game>

  11. Creatures (NPC) • Have parameters • Location, Size, Strength, Health, … • Goal: location NPC is moving towards • Behaviour: class which defines how NPC acts (ie, the AI behind NPC)

  12. Behaviour class • Implements Behaviour interface • Specifies there must be onTick method • Called every tick of game clock • Updates NPC’s position, status, goals, etc according to AI logic • DefaultBehaviour class

  13. 3 steps to Defining new behaviour • Create new class that implements Behaviour • Can copy-and-edit DefaultBehaviour • Specify behaviour • Example: delete goal stuff in DefaultBehaviour • Change XML file to specify new behaviour used by NPC. • Start dungeon, load XML file, run

  14. API • You must familiarise yourself with this as soon as possible. • [Walk through API]. • Go and read the Dungeon XML Primer (on the course Information page). • Play with the game (on the Info page). • Come to the practical on Thursday.

  15. How it works 1: Main • Application enters at main in App class in dungeon.App. • Initial random dungeon fGame built by DungeonBuilder.createDungeon. • Window created as object fMainForm of classDungeonForm. • Event-handling for user interaction and game state updates: fTimerTick and fKeyDispatcher.

  16. How it works 2: Game State • Game state (world) held in an object fgame of Game class. • New initial game state can be loaded from XML from here (implements Persistent class). • XML file gives the data for the initial game state.

  17. How it works 3: Updating • fGame has a method tick() that advances the game by one round. Each round has the following stages: • Each map tile is informed about the new round. • Each treasure item informed about new round. • For each creature in turn, and then for the hero: • The tile they stand upon is informed of this fact. • The creature is prompted to act. • Dead creatures are removed from the game.

  18. How it works 4 • Action listener fTimerTick hears ticks from fGame.tick and updates game via fMainForm.updateGame(). • fMainForm.updateGame() refreshes the User Interface (UI) after the game tick. • fKeyDispatcher in App intercepts presses by user on arrow-keys, so that hero can be moved. This changes game state via fGame.getHero().getMovement() .

  19. How it works 5: Mobs & Behaviour • A mob is a mobile item (orc, creature, hero) which implements the class Mob. • Each mob has various fields which set its properties (strength, energy, treasure list, goals, …, and fBehaviour). • The class Behaviour and its various implementations are used to define the (intelligent) behaviours of mobs.

  20. The brain, not the engine • We are focussed on the AI aspects here. • You won’t have to mess-around with most of the game engine. • You will mostly need to modify Behaviour classes, and a few others.

More Related