Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
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  
  Newbie learning java by writing simple game engine using Eclipse - help needed.  (Read 4043 times)
0 Members and 1 Guest are viewing this topic.
Offline zerodivisible

Junior Newbie

« Posted 2010-06-26 11:16:23 »


Firstly, I would like to write that English is not my first language and I am sorry for all the mistakes.

I am trying to learn Java and I thought, that it would be great if I could write a rather simple game engine - nothing too fancy but on the other hand it would be great if this engine would be a reusable base for few simple games, just to polish my skills. Everything was working fine up to a point - and I don't know right now where I made a mistake.

The problem is, that the main frame is not updating nor redrawing - it shows up when I lanuch the project from eclipse but I can't kill or close it; only stoping the application with the red "Terminate" button in Ecplise.

This is my current eclipse project for this engine - I am using maven for dependency management so I think that this is the only requirement for launching it.

I know that the code is not of the highest quality and there are lots of logical flaws in design but as I had stated - I am just learning. If anyone would have time to check this, I would be very grateful.

Offline DavidX

Senior Newbie

« Reply #1 - Posted 2010-06-26 14:33:57 »

please, create games not game engines.
Offline zerodivisible

Junior Newbie

« Reply #2 - Posted 2010-06-26 15:57:52 »

Hello DavidX and thanks for suggestion, but if I would like to be honest, I think, that I should disagree with You;)

Firstly, when I thought about learning Java, I was thinking something similar to "Hey, I will use the slick engine and try to create some simple 2d game". But after trying to use it, I noticed that I am not understanding Java - I was trying to understand Slick and that was not my objective.

I am almost sure, that my first bigger project will be written in some of the existing frameworks / engines but for now I just keep slick sources as a reference.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DavidX

Senior Newbie

« Reply #3 - Posted 2010-06-26 16:25:09 »

in reply to your question - do you have an infinite loop anywhere? that is probably whats causing it
Offline zerodivisible

Junior Newbie

« Reply #4 - Posted 2010-06-26 16:42:31 »

Yes, there is an infinite loop in my Kernel class, which should fire all the tasks for the game engine - time updating, reading input, game state updating, etc.

The problem is, that the Swing frame is not rendering its contentPane. The sources which I posted are from the version which uses

so I should manually repaint the components. Even if I call repaint() from the MainFrame, its contentPane (which is a class subclassing JPanel) are not updating/redrawing.

Offline DavidX

Senior Newbie

« Reply #5 - Posted 2010-06-26 17:20:39 »

add System.out.println("paintEvent") in your render method and see how often it gets called
Offline zoto

Senior Devvie

Medals: 4

« Reply #6 - Posted 2010-06-26 21:25:08 »

Just quickly looking at the Kernal class I saw a few problems. In the run method you have a local variable called loops that is set to 0 and never changed. In the execute function I'm pretty sure calling remove in the new for loop like that throws an Exception, the easiest solution is to use an old for loop and either iterate backwards or decrement i after you remove an item to compensate.

Refactoring is probably a good idea especially if you are going to show your code to other people.
I would recommend renaming all your variables to more standard names, at least rename the one letter variables.
In the execute function you are iterating over the loop twice, when you should be using an else.
In the run method remove everything except the contents of the inner run function. Then where you call change it to something like:
Thread thread = new Thread( new Kernal() );

As DavidX said use System.out.println to give you feedback on whats happening, you can also use try/ catch blocks and tools built into your IDE like breakpoints and memory viewer.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Ecumene (50 views)
2017-09-30 02:57:34

theagentd (76 views)
2017-09-26 18:23:31

cybrmynd (183 views)
2017-08-02 12:28:51

cybrmynd (181 views)
2017-08-02 12:19:43

cybrmynd (188 views)
2017-08-02 12:18:09

Sralse (195 views)
2017-07-25 17:13:48

Archive (745 views)
2017-04-27 17:45:51

buddyBro (879 views)
2017-04-05 03:38:00

CopyableCougar4 (1428 views)
2017-03-24 15:39:42

theagentd (1318 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 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!