Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  creating a restart button help?  (Read 7949 times)
0 Members and 1 Guest are viewing this topic.
Offline ganaschka

Senior Newbie





« Reply #30 - Posted 2012-07-23 19:00:02 »

Hey do not judge on me  please. I had no idea what in hell Pastebin was. like I said I'm beginner. If there is still problem with Pastebin or something, please post me specifically or give more details.

bests,
ganaschka
Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #31 - Posted 2012-07-23 22:07:34 »

Hey do not judge on me  please. I had no idea what in hell Pastebin was. like I said I'm beginner. If there is still problem with Pastebin or something, please post me specifically or give more details.

bests,
ganaschka

It is great that you've learned to use the code-tags. But as many have tried in various ways to tell you, big chunks of code are hard to read and difficult for anyone but the original coder to understand, especially without comments.

When you're posting large chunks of code while writing a message, in the editor you'll find a link just below the big white text-field, where it says: "Got extraordinary long code dumps? Use our pastebin to keep your thread readable. (link opens in new tab)". If you click the link, a new pane/window will open, and you can paste your code in there. Then you click "Post Code", and you get a link which you can use in your message.

Large chunks of code tend to make people think "Gah, I'm not reading through that!", but if you post a nice, detailed description of your problem, and supply a Pastebin-link, then people interested in helping with the proposed problem, can sit back and look at just the code, and in a separate window, making it much easier to write a reply, without scrolling back and forth.

Hope this helps. As to your problem, it seems you've got plenty of good advice. Just reset the fields associated with your game, and restructure it to use an init-method. It'll make your life much easier.

- Jonas
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #32 - Posted 2012-07-23 22:14:02 »

[code]

I'm cool!

[/code]

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

Senior Newbie





« Reply #33 - Posted 2012-08-04 21:32:39 »

Please help !!! I had just posted "the whole code" on Pastabin
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #34 - Posted 2012-08-04 21:33:31 »

Where?

Offline ReBirth
« Reply #35 - Posted 2012-08-05 05:27:39 »

Even not listed on forum's Lasted Pastebin. Sure use pastebin.java-gaming.org? not the real pastebin.com?

Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #36 - Posted 2012-08-05 06:23:25 »

I don't know but Pasta-bin sounds delicious right now Smiley

Offline ganaschka

Senior Newbie





« Reply #37 - Posted 2012-08-05 17:20:02 »

postes on pastebin.java-gaming.org
Offline ReBirth
« Reply #38 - Posted 2012-08-06 15:35:18 »

Yeah but we need the link. It will appear after you posted the code.

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 114
Projects: 4
Exp: 3 years



« Reply #39 - Posted 2012-08-07 00:34:00 »

Second page, it's not off topic, and we still haven't seen the code  Cranky
epic fail
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #40 - Posted 2012-08-07 01:13:11 »

Maybe he's a troll? Grin

Offline ReBirth
« Reply #41 - Posted 2012-08-07 06:00:35 »

He's not
http://pastebin.java-gaming.org/28886830628
Just need "more" time to adapt Grin

Offline ganaschka

Senior Newbie





« Reply #42 - Posted 2012-08-08 14:26:40 »

OK everyone ! here is the link: http://pastebin.java-gaming.org/6368a201b27
Pestart JBar named "menu" doesnt work underneath the ActionEvent !
Online Danny02
« Reply #43 - Posted 2012-08-08 14:38:54 »

I think you should ditch the idea to restore all state.
Try to encapsulate your game in an own class so that you can create a game Object and connect it to the View(make your game class a Component and add it to a Panel).
When you achieved this you can just throw a game away and create a new one.
Offline ReBirth
« Reply #44 - Posted 2012-08-08 16:16:14 »

Your action method should be placed on JMenuItem rather JMenu. Declare one of that and put it to your "restart" JMenu.

Offline Grunnt

JGO Wizard


Medals: 55
Projects: 9
Exp: 5 years


Complex != complicated


« Reply #45 - Posted 2012-08-09 10:20:35 »

OK everyone ! here is the link: http://pastebin.java-gaming.org/6368a201b27
Pestart JBar named "menu" doesnt work underneath the ActionEvent !

Here's some advice:
1  
2  
private String iconNames[] = {"D:/images/1.png", "D:/images/2.png", "D:/images/3.png", "D:/images/4.png"
                                    , "D:/images/5.png", "D:/images/6.png"};

Tip #1: never refer to files by their full path (i.e. including the D: part). If you do this, then the game will not work when you install it somewhere else.

1  
if(e.getSource() == menu)

Tip #2: I'm not 100% sure but I think you should add a JMenuItem to the JMenu (e.g. a menu "Game" with an option "Restart") for this to work. I'm don't think JMenu generates action events. Read for example: http://stackoverflow.com/questions/9862165/jmenu-actionlistener

1  
2  
        th = new Thread(this);
        th.start();


This is a question, rather: why are you using a thread here? It looks risky.

Offline Grunnt

JGO Wizard


Medals: 55
Projects: 9
Exp: 5 years


Complex != complicated


« Reply #46 - Posted 2012-08-09 10:21:08 »

Your action method should be placed on JMenuItem rather JMenu. Declare one of that and put it to your "restart" JMenu.

This. I kinda overlooked your reply.  Grin

Offline ReBirth
« Reply #47 - Posted 2012-08-09 13:48:59 »

This. I kinda overlooked your reply.  Grin
Shall punish you! Grin Actually that's his main prob.

Offline ganaschka

Senior Newbie





« Reply #48 - Posted 2012-08-09 14:25:00 »

private String iconNames[] = {"D:/images/1.png", "D:/images/2.png", "D:/images/3.png", "D:/images/4.png"t
                                    , "D:/images/5.png", "D:/images/6.png"};
I know but this works well  when it turns out to jar file, otherwise how could be restore images ? how about thread ? what else could be done by running time without using thread ? if there is another way to adapt this solution, how. I need to learn more about it
Offline ReBirth
« Reply #49 - Posted 2012-08-09 14:26:39 »

Don't be strayed by that, focus on your prob. If it's not broke no need to fix.

Offline Grunnt

JGO Wizard


Medals: 55
Projects: 9
Exp: 5 years


Complex != complicated


« Reply #50 - Posted 2012-08-09 15:40:30 »

private String iconNames[] = {"D:/images/1.png", "D:/images/2.png", "D:/images/3.png", "D:/images/4.png"t
                                    , "D:/images/5.png", "D:/images/6.png"};
I know but this works well  when it turns out to jar file, otherwise how could be restore images ? how about thread ? what else could be done by running time without using thread ? if there is another way to adapt this solution, how. I need to learn more about it


Agreed with ReBirth, don't let me confuse you  Grin The timer thing I'm not sure about myself, sorry for bringing that up. The images you can just put in the same (or a sub)directory of the jar file, e.g.:

game.jar
images/1.png
images/2.png
...

Then you can load the images using:
1  
2  
private String iconNames[] = {"images/1.png", "images/2.png", "images/3.png", "images/4.png"
                                    , "images/5.png", "images/6.png"};


Even when your game is on someone else's computer, e.g. one that does not have D: But maybe you knew that already.  persecutioncomplex

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 114
Projects: 4
Exp: 3 years



« Reply #51 - Posted 2012-08-09 18:29:04 »

Hm. I always used an array of File objects, and then used getURI().
Offline masteryoom

JGO Coder


Medals: 5
Projects: 3


If you look closely, you might see it turning...


« Reply #52 - Posted 2012-11-06 07:17:30 »

@ganaschka, why don't you create a variable that holds either one or two ( or TRUE or FALSE) like so:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
bool myrestart;
myrestart = true
// if button activates
myrestart = false;
while (myrestart = false){
//set all variable to 0
myrestart = true;
}
//go back to code
mycode()

And that only took me about 10 seconds   Cool
(please check that the code syntax is correct Grin)

Smiley
Pages: 1 [2]
  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.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (26 views)
2014-04-14 17:35:47

Porlus (43 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (224 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!