Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2176
| Newsgroups | comp.lang.java.help |
|---|---|
| Date | 2012-10-25 01:05 -0700 |
| References | <a02ca455-c62d-4397-8673-26489e368630@googlegroups.com> <k6a2po$ulm$1@dont-email.me> <0a94edb9-529b-4df8-8b89-97778cacbd15@googlegroups.com> |
| Message-ID | <31988b9d-9d7c-41a5-96cf-535787dc2f83@googlegroups.com> (permalink) |
| Subject | Re: Lunar Lander |
| From | Lew <lewbloch@gmail.com> |
sqwundle@ wrote: > Knute Johnson wrote: >> sqwundle@ wrote: >>> hello im making a lunar lander program but im having trouble with the >>> accleration and when you click the left and right arrows the ball goes >>> flying can anyone help fix my code > > [snip] > >> Take a look at my Asteroids game code; >> http://rabbitbrush.frazmtn.com/asteroids.html ... > im a beginner at java so reading long code like that is confusing. > what exactly do i need to fix my problem This is a normal situation at beginning stages. Key to your success will be patience. To read long code, first get a good editor like various windowed versions of vi or emacs, or any IDE that does Java, and set your preferences to show methods in boldface and type names (classes and interfaces) in a notable distinguishing color or boldface. You can do more than that, but that's up to you. Copy and paste the code into your nifty editor. Start by reading only the type declarations and method declarations and invocations. Ignore variables, logic not directly talking to method invocations and other fluff. Do read comments, of course. Read the whole code just comments, types and methods. Twice. In my answer to your question upthread I read the whole code you posted. Good job, by the way, posting your code. Excellent way to show your difficulty. But I skipped some details, like understanding your specific velocity deltas. Daniel and Knute gave you the foundation for a really good solution. I figure they read your whole code, too, judging from the detail of their comments. So at least three people have read your whole code that you posted, expecting and hoping that people would read it, as we did. And code known to have a bug or two in it but without specific knowledge of where to look, or why certain decisions (like delta values chosen), and the like, now that if any does, deserves to be called confusing. But it wasn't bad code, really. It had the errors Daniel pointed out, and the architectural flaws Knute showed you how to fix, but that just shows you that programmers accepted your start and showed you how to go the next lap. So fix those minus-equals operators and restructure your code Knute's way. You have to make some deep changes,and learning it differently from reading Knute's examples will nearly certainly take at least four times longer. Here's what you'll learn, if you are patient with your confusion and just go through the code, and use it - I mean compile and freaking run it. You don't have to worry about the compiler or JVM getting confusd. - How to separate GUI and computation work into the EDT (look it up, "Java Swing EDT Event Dispatch Thread") and worker threads, without having to master threads first; - How to hook GUI components together; - How to name types, variables and methods and such; - How to draw custom thingies into a GUI without screwing up the GUI; - How to deal with timing; - How to deal with timing; - Event-driven programming; - How to make self-documenting (Knuth's "literate") code; - How to structure a program compactly and completely and logically; and far too much more to mention here. Now how you gonna learn all that any quicker than the week or so Knute's stuff'll teach you? Remember - actually run it. From the command line, e.g., $ java com.knutejohnson.games.asteroids.Asteroids & and from any IDE or other way you like, as well. -- Lew
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Lunar Lander sqwundle@gmail.com - 2012-10-24 15:11 -0700
Re: Lunar Lander Knute Johnson <nospam@knutejohnson.com> - 2012-10-24 17:57 -0700
Re: Lunar Lander sqwundle@gmail.com - 2012-10-24 18:32 -0700
Re: Lunar Lander Knute Johnson <nospam@knutejohnson.com> - 2012-10-24 21:11 -0700
Re: Lunar Lander Lew <lewbloch@gmail.com> - 2012-10-25 01:05 -0700
Re: Lunar Lander Lew <lewbloch@gmail.com> - 2012-10-24 18:31 -0700
Re: Lunar Lander Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-10-24 20:37 -0700
csiph-web