*
The moose likes Game Development and the fly likes Making Typing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Making Typing "Game", any tips or pointers before I start?" Watch "Making Typing "Game", any tips or pointers before I start?" New topic
Author

Making Typing "Game", any tips or pointers before I start?

john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Making Typing "Game"...Any tips or pointers before I start?
I am probably going to making an Applet version and an application version.
Thanks,
cc11rocks


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Well, I started...I made a free-form counter and made the general idea...


This is just the beginning. I will update it as soon as there is a major update. I will add more to this free-form area, such as time options. I may make a tutor type tab also. I am starting small, but going big soon. Thanks!
Wish me luck (and give me advice please),
cc11rocks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

john price wrote:Wish me luck (and give me advice please)

- Make your class final
- Make your fields private and where possible, final
- Use proper names for variables. Haha is not a proper name. Sixty is a terrible name for a variable that can be something other than 60.
- Instead of KeyListener, use KeyAdapter
- Don't use null layout. Really don't do this.
- You should also work on your indentation. It's hard to see which code belongs in which block.

Good luck.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Stephan van Hulst wrote:
john price wrote:Wish me luck (and give me advice please)

- Make your class final
- Make your fields private and where possible, final
- Use proper names for variables. Haha is not a proper name. Sixty is a terrible name for a variable that can be something other than 60.
- Instead of KeyListener, use KeyAdapter
- Don't use null layout. Really don't do this.
- You should also work on your indentation. It's hard to see which code belongs in which block.

Good luck.


Here is the new one. I added some features. I am going to be making a tracker at the top (with the WPM and time counters), whether you are meeting your WPM goal or not. I will update this when I finish that...I heeded to all your recommendations except for the null layout suggestion. I love it too much to do away with it. Sorry. Anyway, thanks for all your help. If you have any recommendations besides the null layout, please be sure to share!
Thank you very much,
cc11rocks


john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

UPDATE: An online version has been created! It is running the latest update (not necessarily the latest code) at:
http://techcomputer1.webs.com/
Scroll to the very bottom to see it...It is the same as the application version. Please make comments and suggestions about usability, user-friendliness, and anything you can think of.
Thanks,
cc11rocks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Yes, when I resize my browser window to make it smaller, and the applet doesn't fit into the window completely, the scrollbar of your text area disappears over the edge. Can you make it automatically resize when my browser window gets smaller?
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Stephan van Hulst wrote:Yes, when I resize my browser window to make it smaller, and the applet doesn't fit into the window completely, the scrollbar of your text area disappears over the edge. Can you make it automatically resize when my browser window gets smaller?


I don't know how to do that. I know basic HTML and Java. I can do that, but you would have to show me how or give me a resource to find it. I will look for it.
Thanks,
cc11rocks

EDIT: I may have fixed it. Test it now.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Nope. You will need JavaScript to resize the applet when the browser window resizes. Try resize applet.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Stephan van Hulst wrote:Nope. You will need JavaScript to resize the applet when the browser window resizes. Try resize applet.


That is what I did to "fix" it. Obviously, it didn't work.



I copied, pasted, and slightly modified it...
cc11rocks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

First of all, your applet element does not specify a name attribute. Furthermore, did you do this?
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I just now did the second thing. I also added a "name" perimeter in the <APPLET> code.

It isn't working. Plus, I am having issues with the Applet. I coded it right (the application works), but it isn't working correctly. I know it is working correctly because I ported the Applet code to the application and modified it to fit JFrame. It works properly in the application, but not the Applet...
cc11rocks

EDIT: Now the Applet is working properly. I have no idea what was wrong, but it had nothing to do with Java or HTML. Javascript issue I think...
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Okay, the applet resizes now, but the text area within the applet doesn't resize, so when the applet gets smaller, the scrollbar and buttons still disappear over the edge. Maybe you can fix this?
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Stephan van Hulst wrote:Okay, the applet resizes now, but the text area within the applet doesn't resize, so when the applet gets smaller, the scrollbar and buttons still disappear over the edge. Maybe you can fix this?


I don't understand this. I still see no difference. Is it because of my null layout?
Thanks,
cc11rocks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Well, when the applet itself gets smaller (because the browser window gets smaller), it would be nice to resize the components inside the applet as well, wouldn't it? So the button and the text area and everything always try to squeeze into the available space, instead of being cut off by the edge of the applet.

Right now the applet is resizing correctly (even though it's annoying that the browser scrolls all the way back up the page again), but the components inside the applet remain the same.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Stephan van Hulst wrote:Well, when the applet itself gets smaller (because the browser window gets smaller), it would be nice to resize the components inside the applet as well, wouldn't it? So the button and the text area and everything always try to squeeze into the available space, instead of being cut off by the edge of the applet.

Right now the applet is resizing correctly (even though it's annoying that the browser scrolls all the way back up the page again), but the components inside the applet remain the same.


I'm assuming because of my null layout? Or if not, then what?
Thanks,
cc11rocks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Yes, because of your null layout. Technically you can write a bunch of listeners that will reposition all your components when the container changes, but really, that's just a hack in order to avoid using layout managers.

John, I'm not trying to pester you, but your applications will be taken a lot more seriously if you learn how to work with layout managers. If you want, I can convert your current applet to show you how it's done, and then you can feel for yourself how much nicer your programs become.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

If you will do this one project for me, I will start using layout managers. I was messing with the Applet, so it's kinda jacked up. I will just port to Applet if you fix application. Thanks! It's really easy to convert, so if you could fix this, that would be great! Here is updated code (I think) :



cc11rocks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Run the example I gave you, and try resizing the frame. Notice how the components resize and move around in order to adapt to the new window size.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

Wow. You changed everything. I do have two questions (they're pretty stupid)...
What are the "@override"s for? For stuff like toString, I understand that. For stuff like actionPerformed and keyEvent, I don't understand why it can't just be the regular way.
Where is the timer?
Thank you for doing this. It is way more professional than I had it. I'm not sure I'm going to be able to keep this standard.
I am at work, so I won't be able to run this code for a few hours. I am a bit confused. I understand most of it, but the variables are different (can figure that out later). You also used more OOP, so I have to examine that a little bit closer. I understand for the most part, but I don't see the timer, or where it is calculated (I see the time when you originally change it, but not during typing).
How did I do this project so wrong? Lack of experience? Or just stupidity?
Thanks,
cc11rocks

EDIT : Unrelated, but can't wait for Java 7! Hopefully be able to stream live webcast in the background (I registered and got passkey ) at my work. The site that is up I can access. But these are really old computers with old software and an average internet connection.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3594
    
  14

Oh no, this example demonstrates the layout only. I tossed out all your business logic for sake of keeping the example simple. That's why there's also no timer.

You'll see for yourself when you get the chance to run this code. Let me know what you think then.

You can use @Override for overridden methods as well as method declarations inherited from interfaces. Usually I only use it when I override a method from a superclass, but NetBeans gives me warnings when I don't use it for interfaces as well.
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I do see, thank you! I had to look up what "business logic" was, but I think I understand. Now I just have to add the business logic and convert this to an application, right? By the way, this is the easy part of my app if you were wondering. I am making a lesson tab for learning to type.
Thanks,
cc11rocks
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

New post...
 
 
subject: Making Typing "Game", any tips or pointers before I start?
 
Similar Threads
Porting from Core Java to J2ME
making a game
How to write data to tape drive
how do i start preparing
how to make my game program run , just in double click ?