Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
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 would I restart a class?  (Read 1570 times)
0 Members and 1 Guest are viewing this topic.
Offline K.I.L.E.R

Senior Devvie

Java games rock!

« Posted 2004-01-09 09:38:03 »

I'm finished my noughts and crosses game, almost. I gave the option to restart or quite the game after the game ends.

How would I restart my game?
I tried restarting the applet (it's in a JFrame) by calling destroy and then init method.
Doesn't work.

Any ideas?


Is there a name for a "redneck" programmer?

Unemployed. Wink
« Reply #1 - Posted 2004-01-09 13:23:17 »

Separate your frame/applet code and game code clearly. So when restarting, just re-create or reset the game stuff.
Offline erikd

JGO Ninja

Medals: 16
Projects: 4
Exp: 14 years


« Reply #2 - Posted 2004-01-09 21:32:57 »

Try to think of what the Applet actually *is*: An online application embedded in a web page, nothing more, nothing less.
You don't want to restart the Applet, you want to restart your *game*, not the whole applet. Try to refactor your code, so you can simply call Game.start() or something and that your class extending Applet will be dumb enough to just show what your 'Game' class does without knowing much else.
A (shaky) analogy: When you start an application on your PC, you're not restarting your whole PC, are you?

(meant as constructive criticism  Smiley)


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline K.I.L.E.R

Senior Devvie

Java games rock!

« Reply #3 - Posted 2004-01-09 21:51:27 »

Thanks, I think I know where you guys are going with this. Smiley

I do have my class constructor, I use that to start my program.
I need a stop method that will act as a destructor.
I will experiment with this.

Is there a name for a "redneck" programmer?

Unemployed. Wink
Offline Jeff

JGO Coder

Got any cats?

« Reply #4 - Posted 2004-01-13 23:27:01 »

Your starting object that is called  by the applet is like any other object.  If you return out of it and there are no other references it becomes a candidate for collection.

Not that you really should care, all you should really need to do is return any resources it grabbed and exit abck to your launch code.

This can be complciated IF you are using static varibales anywhere.  These will need to be set back to their initial states by your code.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

basil_ (42 views)
2015-09-30 17:04:40

shadowstryker (21 views)
2015-09-29 15:55:06

TheSpaceHedgehog (27 views)
2015-09-29 01:58:48

GamerC4 (50 views)
2015-09-24 21:10:38

GamerC4 (70 views)
2015-09-24 21:09:48

htuy (25 views)
2015-09-24 04:57:24

htuy (35 views)
2015-09-24 04:56:35

htuy (25 views)
2015-09-24 04:56:09

htuy (26 views)
2015-09-24 04:47:33

Roquen (63 views)
2015-09-21 12:54:28
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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‑
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!