Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
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  
  How do you "wrap" your games?  (Read 3546 times)
0 Members and 1 Guest are viewing this topic.
Offline mast3rpyr0

Senior Newbie


Medals: 1



« Posted 2012-03-02 03:37:33 »

I'm starting a project that will start at a login screen, move to a lobby system, and then the game will start. How would you guys go about designing the flow of your application? Would you have a Game class with the main method your game loop and your different menus? Or would you have a MainApplication class, that will only create the window, and have that create a LoginScreen, which calls the Lobby, which calls the Game class?
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #1 - Posted 2012-03-02 03:40:12 »

Usually some kind of handler, that has all of the different screens needed. The application goes back up, and changes what screen to render as it runs.
 

Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #2 - Posted 2012-03-02 14:09:11 »

I use a statemanager that uses a String "state" and a "setState". When I need to change state (ESC is pressed or something) I simply do

1  
main.setState = "menumain";


and in the main method

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public void tick()
{
      ticks++;
      this.state = statemanager.state;
     
      if ((setState != state) && (!setState.equals("null")))
      {
         if (setState == "quitting")
         {
            if (!applet) stop();
            if (applet) setState = state;
         }
         
         statemanager.setState(setState);
         setState = "null";
      }


This just sets the state only if setState is not equal to null and setState does not equal to state. This probably isn't the best way to do it, but it works for me.

-Nathan

Check out my website!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2012-03-03 02:42:07 »

Don't use == and != to check for String equality!!!!!!!!!! Use the equals(String) method!!!! T______T

Also, why Strings? this will cause your tick and render methods to have loooong if-else statements! It is best to have a class called Screen and then the main class just calls the Screen's update and render methods.

Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #4 - Posted 2012-03-03 02:55:57 »

What would this do to have long if-else statements, and how could it affect rendering? And I changed it to .equals. Forgot for that one.

-Nathan

Check out my website!
Offline UprightPath
« Reply #5 - Posted 2012-03-03 02:57:12 »

As an aside!

You can use ==/!= if you're absolutely sure that your strings will never change during execution. Take a look at http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html

However, using .equals(string) is probably best. :3

Offline sproingie

JGO Kernel


Medals: 202



« Reply #6 - Posted 2012-03-03 03:16:28 »

The first thing .equals() does is check reference equality.  Don't try to be smarter than the language, use .equals() to compare strings, period.
Offline RylandAlmanza

Junior Member


Medals: 3



« Reply #7 - Posted 2012-03-03 03:38:37 »

Don't use == and != to check for String equality!!!!!!!!!! Use the equals(String) method!!!! T______T

Also, why Strings? this will cause your tick and render methods to have loooong if-else statements! It is best to have a class called Screen and then the main class just calls the Screen's update and render methods.
OFFTOPIC:You are the most knowledgeable 16 year old programmer I've ever seen. I just can't get over how you know so many things even though you're only 16! Most 16 year olds use things like game maker or something, and call themselves programmers, but your ability far surpasses mine! (That's not saying much, though, because my ability is pretty bad.) Sorry to go off topic, just wanted to make sure you knew how intelligent you are, lol. Smiley
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #8 - Posted 2012-03-03 04:02:08 »

Don't use == and != to check for String equality!!!!!!!!!! Use the equals(String) method!!!! T______T

Also, why Strings? this will cause your tick and render methods to have loooong if-else statements! It is best to have a class called Screen and then the main class just calls the Screen's update and render methods.
OFFTOPIC:You are the most knowledgeable 16 year old programmer I've ever seen. I just can't get over how you know so many things even though you're only 16! Most 16 year olds use things like game maker or something, and call themselves programmers, but your ability far surpasses mine! (That's not saying much, though, because my ability is pretty bad.) Sorry to go off topic, just wanted to make sure you knew how intelligent you are, lol. Smiley
Hehehe thanks Grin

Offline Cero
« Reply #9 - Posted 2012-03-03 11:11:23 »

just use Enums for states, best practice
I tend to use constant ints and stuff, but sometimes I think in C++ terms


You are the most knowledgeable 16 year old programmer I've ever seen.
I agree
When I was 16 I was probably using BORLAND C++, or maybe still Visual Basic

but yeah you can't compare string-values with ==, strings are objects not primitives :>

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 361
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #10 - Posted 2012-03-03 12:35:04 »

When you think about it, someone 16 years old who started at 7 or 8 has already got the sort of experience that normally triples someone's salary in the real world... start young and you will be an absolute master by the time you're 30.

Cas Smiley

Offline ReBirth
« Reply #11 - Posted 2012-03-03 12:50:46 »

Don't use == and != to check for String equality!!!!!!!!!! Use the equals(String) method!!!! T______T

Also, why Strings? this will cause your tick and render methods to have loooong if-else statements! It is best to have a class called Screen and then the main class just calls the Screen's update and render methods.
OFFTOPIC:You are the most knowledgeable 16 year old programmer I've ever seen. I just can't get over how you know so many things even though you're only 16! Most 16 year olds use things like game maker or something, and call themselves programmers, but your ability far surpasses mine! (That's not saying much, though, because my ability is pretty bad.) Sorry to go off topic, just wanted to make sure you knew how intelligent you are, lol. Smiley
Hehehe thanks Grin
Watchout, we got badass here!
Me at 16 still playing VB6.

Btt, follow his and Cero's way.

Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #12 - Posted 2012-03-03 15:40:14 »

I apologize for my terrible error with those strings hahaha. I try to always use .equals, but that time I just forgot and it worked so I didn't catch it.

I am 17 and started at 12 programming on my TI-83 calculator Smiley

-Nathan

Check out my website!
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #13 - Posted 2012-03-03 23:07:26 »

When you think about it, someone 16 years old who started at 7 or 8 has already got the sort of experience that normally triples someone's salary in the real world... start young and you will be an absolute master by the time you're 30.
$$$___$$$

Offline BoBear2681

JGO Coder


Medals: 18



« Reply #14 - Posted 2012-03-04 00:01:21 »

If only you could teach yourself what it takes to be a "consultant" as a teenager...
Offline ReBirth
« Reply #15 - Posted 2012-03-04 03:47:15 »

Now ra4king, stay out from facebook and chicks. Back to your desk and work! Angry

Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #16 - Posted 2012-03-04 04:32:21 »

Nooooooooooooooooooo Cry

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.

atombrot (23 views)
2014-08-19 09:29:53

Tekkerue (22 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (57 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (36 views)
2014-08-06 19:49:38

BurntPizza (66 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!