Re: The character. You appear to launch into your main loop from the RandomTerrain constructor. The main loop calls RandomTerrain.tick() and RandomTerrain.render(). I can't see anywhere in the provided code, particularly in the loop, where you call MainPlayer.draw(), possibly why it isn't rendering.

By the way, I wouldn't launch the loop from within the RandomTerrain constructor, it seems bad form to me. You could remove the call from within the constructor, and call it from elsewhere once the object has been instantiated. I.e. the object that makes the new RandomTerrain();/your main class could subsequently call randomTerrain.loop();, and launch the loop.

Re: The character. You appear to launch into your main loop from the RandomTerrain constructor. The main loop calls RandomTerrain.tick() and RandomTerrain.render(). I can't see anywhere in the provided code, particularly in the loop, where you call MainPlayer.draw(), possibly why it isn't rendering.

By the way, I wouldn't launch the loop from within the RandomTerrain constructor, it seems bad form to me. You could remove the call from within the constructor, and call it from elsewhere once the object has been instantiated. I.e. the object that makes the new RandomTerrain();/your main class could subsequently call randomTerrain.loop();, and launch the loop.

Thanks, its now drawing the player, however I couldnt figure this out before, but for some reason the player moves really slow, and the physics are inverted, so it falls up instead of down, ideas?

and I'll have a look at calling loop from the main class after I get this working,Thanks,- Dan

I can't see anything glaringly obvious in your MainPlayer class that could be causing this. Can I suggest that you perhaps do some println's on your x, y, xspeed and yspeed variables in the logic() method, and compare the values to what you expect. If the values are correct, then it could be an issue with rendering; but explore this option later.

Slow as in 'smooth but slow'? Then the easiest answer is to increase your speed variables.

Or slow as in 'clunky'? This isn't so easy. Currently I can't see where or how you are controlling timing. It appears your game loop is running flat-out (i.e. not limited by Thread.sleep() or Display.sync()). Furthermore, you are using fixed updates, so that each time through the loop, the players speed and position is updated irrespective of how long the last loop took. This generally leads to choppy movement. In many cases, a game loop implements a timing mechanism, so that movement can be smoothed, due to the irregular time of updates. It also ensures that the scene appears to move at the same rate, independent of how many FPS/UPS you are running at. There are plenty of resources on this forum about game loops and timing, which a quick search will reveal. (There is a good tutorial floating around from memory).

I had a go at using that code with the other code I have which you helped me write, and I came across issues when trying to add CanMove to my player class, because the pixel precision isnt working due to conflicts with the way RandomTerrain is drawing tiles, this is about as far as I got:

Dan, no offense but you need to start at the basics. Obviously this is above your head (as other people have pointed out). Right now it seems that you are just copying code from other people and trying to make it work which is the wrong way to program. Write your own code so you understand what its doing, and so you learn when you complete your task.

Dan, no offense but you need to start at the basics. Obviously this is above your head (as other people have pointed out). Right now it seems that you are just copying code from other people and trying to make it work which is the wrong way to program. Write your own code so you understand what its doing, and so you learn when you complete your task.

Ok then got any good places for me to start? (Prefer online things to books)

So I decided to have another proper go today, and I got really really close to making it work, no launch errors now, but canMoveP is null :/ and I get this as well ExceptionInInitializerError in RandomTerrain

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