Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Game design  (Read 983 times)
0 Members and 1 Guest are viewing this topic.
Offline _Al3x

Senior Devvie


Medals: 7


Indie Games FTW!


« Posted 2012-03-18 14:35:18 »

Hello everyone! I'm here once again to ask you something!    Roll Eyes

I'm going to try to implement ALL the things you guys been suggesting me. Starting from GAME STATES.

So I took what ra4king and zngga told me here and try to implement it.

This is what I have so far.

|- engine
||- GameEngine: Creates a JFrame and adds a canvas in it. Has the main loop |(while (isRunning)), inside it, there's the time handling, the update and the |render methods.
|
|- entities
||- Entity: Base class for every object.
||- All other entities that extends Entity.
|
|- main
||- Main: A simple main method that turns on the GameEngine and runs the |run() method.
|
|- states
||- ScreenState: Base class for evey state in the game, has update(), ||render(), enterState(), leaveState() and mouse and keyboard handling.
||
||- Other states are GameMapViewState, GameMenuState and GamePlayState

Is this ok? Am I on the right track?
How do I implement the KeyInputHandler? And if I want to add a mouse input handler?

Things to do:
- Change between states (100%)
- Support mouse and keyboard input (100%)
- Fix time managment (ticks, fps, anything else) (70%)
- Add animation (0%)
- Support spritesheets (0%)
- Add sounds & music (10%)
- Separate core engine from game engine (45%)

Edit: 6/4/12: Modified the OP to add TODO things and made the "design tree"
Edit: 9/4/12: Added things to the TODO list, plus % done and colors Smiley

Offline 65K
« Reply #1 - Posted 2012-03-18 17:31:24 »

Two points from me:
- sleep(10) is not that good (precision is platform dependent, not reliable). I think there is a verbose thread somewhere here about timing
- I wouldn't expose attributes of class Entity as public attributes

Mouse and keyboard input ?
Just call addMouseListener() or addKeyListener on your UI component. But be careful about threading issues. Listeners will be called from the AWT thread.

Offline _Al3x

Senior Devvie


Medals: 7


Indie Games FTW!


« Reply #2 - Posted 2012-03-18 17:44:12 »

Thanks for your reply  Cheesy

- I'll look later about timing, right now I'm working just on design, but thanks, I'll keep it in mind (and noted on my to-do list).
- Class Entity was very quick made by copy pasting things, I will make it better soon!

So, every game state should have a mouse and keyboard listener?
And about threading, I'll keep it very simple for now Smiley

Thanks again! Cheesy

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 65K
« Reply #3 - Posted 2012-03-18 17:52:56 »

So, every game state should have a mouse and keyboard listener?
You could add one pair of listeners once and forward events to the current state. Otherwise you would rather have to attach and detach listeners on every state change.

And about threading, I'll keep it very simple for now Smiley
That's good. Nevertheless you have to be aware of the issues of Swing not being threadsafe, how to update the UI, about visibility of variables and locking maybe.

Offline ra4king

JGO Kernel


Medals: 355
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2012-03-18 17:54:33 »

Awesome looking code, couple thoughts from me too:
- You don't have to get the screen size and do all that math to center the window, a simple call to frame.setLocationRelativeTo(null) does just that.
- Use this code to force Windows to use the high resolution timer so sleep(10) would become more accurate, like 65K mentioned.
- To get events, just create an inner class in GameEngine that implements KeyListener, MouseListener, and MouseMotionListener. This way, you can just propagate the events to the currentState's appropriate methods.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Gibbo3771 (12 views)
2014-11-24 19:59:16

trollwarrior1 (35 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!