Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (563)
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.

Kev

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
1  
2  
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:
1  
this.rotation = (float) Math.toDegrees(Math.atan2(dy, dx)) + 89.65f;

should fix the problem.

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

and change the 3rd line of the update function to:
1  
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.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
   @Override
   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;
   }

   @Override
   public void render(GameContainer gc, Graphics g) {
      sprite.setRotation(Math.round(this.rotation));
      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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (28 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (103 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
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!