So Im making a game that's a mix of Visual Novel and Tactical RPG. Essentially the game flows from one event to another based on a script. Decisions along the way can alter the path the player takes through the story. There are two general types of events: Story events which tell the story, and Battle events in which the player must fight enemies in a Tactical RPG fashion. Basically its like Fire Emblem but with branching paths.
So what i need help with is:
1) Getting the game to go along with the story as well as player decisions (namely the branching paths).
2) Getting the game to switch from "Story mode" to "Battle mode"
3) Getting all of the above to display on the screen.
3.5) To be more specific on number 3, theres an awful lot of data related to graphics (like monster sprites) that are all the way down in Battle that need to be brought up to the Main class to be displayed, while Battle is running a loop and without interfering with said loop.
4) Making sure i dont get something like the screen not updating until the battle loop is finished (I have a funny feeling that my current main class will end up doing this).
5) How would I go about getting, say, PNG files to display using the opengl Display?
Right now the problem is more of overall design rather than actual programming, so for now i just need general suggestions like what kinds of classes to make and how to have them interact with each other and ultimately how to get the main class shown below to work with them. Also I pretty much already have the battle system designed, so im good on everything that takes place WITHIN a "Battle Event"; its just everything outside that i need help with. Thanks to anyone who can help.
The work ive done so far:
For numbers 1 and 2, my idea is to have a Script class, which contains an Array of Scenes (Scene is an interface with one method play()) and has a method to read them called read(). Two classes, Story and Battle, implement Scene. When play() is called on a Story, it reads through the dialogue until it runs out of dialog to display, at which point read() moves on to the next Scene. When play() is called on a Battle, the game goes through a battle (it should be noted that in this setup, Battle.play() contains the battle system.).
Here's the main class (there is some lwjgl and opengl involved, but just a little bit)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| package game;
import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display;
public class Game {
public static final String GAME_TITLE = "My Game"; private static final int FRAMERATE = 60; private static boolean finished;
public static void main(String[] args) { try { init(); run(); } catch (Exception e) { e.printStackTrace(System.err); Sys.alert(GAME_TITLE, "An error occured and the game will close."); } finally { cleanup(); } }
public static void init() throws Exception { Display.setTitle(GAME_TITLE); Display.setVSyncEnabled(true); Display.create(); }
public static void run() { while (!finished) { Display.update(); if (Display.isCloseRequested()) { finished = true; } else if (Display.isActive()) { Display.sync(FRAMERATE); } else { try { Thread.sleep(100); } catch (InterruptedException e) { } } } }
public static void cleanup() { Display.destroy(); } } |