Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Slick2D - Text Glitches on: 2010-04-25 09:17:50
Fixed in the SVN, no release including the fix yet.


Thanks a lot mate. Smiley
2  Game Development / Newbie & Debugging Questions / Slick2D - Text Glitches on: 2010-04-25 08:51:38
I've been working on a little shooter game for a few hours now, and have come across a problem when drawing text. When I draw a String of text on the screen, a completely different string will be drawn instead.

For example; in the 'render' method (which passes two methods, GameContainer and Graphics), if I were to call
g.drawString("This is some text", 15, 60);
g.drawString("This is some more text.", 15, 75);

It would draw both strings normally for a little while, then start drawing 'This is some text' for both strings after a few minutes.

Does anyone know the cause? Or a possible solution?
3  Game Development / Newbie & Debugging Questions / Re: 'Follow' problem. on: 2010-02-10 20:48:23
Changing the 3rd line of update to:
this.rotation = (float) Math.toDegrees(Math.atan2(dy, dx)) + 89.65f;

should fix the problem.

I would recomend adding a member variable like:
final static float ROTATION_OFFSET = Math.toRadians(89.65f);

and change the 3rd line of the update function to:
this.rotation = (float) (Math.atan2(dy, dx) + ROTATION_OFFSET);

Always keeping the rotation variable in radians will help a lot with avoiding errors like this. If you ever want the rotation in degrees, to show the player or something, just convert it on the fly.

The problem isn't the rotation (Although I did change my method to fit yours a bit more). It faces the player just fine.

The problem is when the player is moving, the enemy will stop moving towards the enemy, and instead do these weird little circles, causing him to be nearly stationary.

What zoto said, and also make sure that the angle you're applying cos and sin to is in radians.

I noticed when you quoted me, you had commented out the rotation offset.

The reason I've got that is because my sprite wouldn't face the right direction (he'd face 90 degrees counterclockwise of the direction he's supposed to face.

Edit: I fixed it, I figured out what my problem was. Thanks to the two of your for your help. Much appreciated.
4  Game Development / Newbie & Debugging Questions / 'Follow' problem. on: 2010-02-10 18:15:49
What a great first post, eh?

Well, I started working on a simple top-down shooter yesterday (Using the Slick library). I've made the enemies follow the player, but it's somewhat buggy.

   public void update(GameContainer gc, int delta) {
      float dx = ((Engine.getPlayer().getLocation().x + 10) - this.location.x);
      float dy = ((Engine.getPlayer().getLocation().y + 10) - this.location.y);
      this.rotation = (float) Math.toDegrees(Math.atan2(dy, dx) + 89.65f);
      final float SPEED = 1.0f;
      this.location.x += Math.cos(this.rotation) * SPEED;
      this.location.y += Math.sin(this.rotation) * SPEED;

   public void render(GameContainer gc, Graphics g) {
      sprite.draw(this.location.x - (sprite.getWidth() / 2), this.location.y - (sprite.getHeight() / 2));

It works fine when the player isn't moving, but when the player starts moving, the enemy starts doing all of these little circles (not rotation, but location) until the Player stops moving.

Anyone know what the issue might be?
Pages: [1]
EgonOlsen (59 views)
2018-06-10 19:43:48

EgonOlsen (42 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (240 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

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 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!