Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (307)
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] 2
1  Game Development / Newbie & Debugging Questions / Re: Getting the sinking feeling on: 2012-07-11 00:00:57
Thank you,

I made the changes you suggested and it is working fine.

private void gravity() {

      float Y = sprite.getY();

      speed += accel * Gdx.graphics.getDeltaTime();

      if (sprite.getY() <= floor && speed < 0) {
         grounded = true;
         speed = 0;
         sprite.setY(floor);
      }
      Y += speed * Gdx.graphics.getDeltaTime();
      sprite.setY(Y);
   }
2  Game Development / Newbie & Debugging Questions / Getting the sinking feeling on: 2012-07-10 23:42:18
I am implementing basic gravity+floor collision but due to the speed always increasing, after I hit the floor I sink like im stood in quicksand, the issue is that if I put an 'if !grounded around the gravity calculations jumping will not work.

Any ideas?

private void gravity() {
      
      float Y = sprite.getY();

      speed += accel * Gdx.graphics.getDeltaTime();
      Y += speed * Gdx.graphics.getDeltaTime();
      sprite.setY(Y);

      if (sprite.getY() <= floor) {
         grounded = true;
         speed = 0;
      }
   }


public void controls() {
      if (Gdx.input.isKeyPressed(Keys.W) && grounded) {
         grounded = false;
         speed = 300;
      }
}
3  Game Development / Game Mechanics / Re: npc move to X,Y smooth on: 2012-05-16 18:20:43
Cheesy Thanks

I was having a look at this: http://www.aurelienribon.com/blog/projects/universal-tween-engine/

Its looks to be what I am looking for, will have a play when I get home.
4  Game Development / Game Mechanics / Re: npc move to X,Y smooth on: 2012-05-16 18:15:01
My original idea was to have each npc take its current position and it target position and create a spline path to follow, I am researching it now but didnt know if you guys had any better ideas?
5  Game Development / Game Mechanics / npc move to X,Y smooth on: 2012-05-16 18:00:10
Good afternoon,

I am working on a A.O.E style game and am currently implementing the target positions for villagers,
I do not need to do any A* pathfinding due to there being no obstacles but I also dont want to do some ugly: if (x < x2) x++; style movement as its ugly when the npc reaches its destination on one axis and then just walks strate, is there any nice, smooth technique for me to give an npc a destination for it to move and have it follow a soft like to its destination.

Martin
6  Game Development / Game Play & Game Design / Re: Proof of concept video. Slick2D tank game on: 2012-04-29 23:06:22
That's pretty cool. How are you handling the angle of fire (trajectory)?
7  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-23 13:20:38
Thanks tom, That worked exactly as I needed it to.

8  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-23 10:35:27
I had to change my approach due to LD48 time constraints and my lack of knowlage on the subject.

But what I wanted was to have an image of some stars, ontop of that an image of terrain and ontop of that an circular image to crop the terrain to a circle and allow me to see the image of the stars underneath.
9  Java Game APIs & Engines / Engines, Libraries and Tools / Basic Sphere with texture in libGDX on: 2012-04-21 22:48:41
How can I go about making a basic sphere in libgdx with a texture applied. I do not want lighting.

If i use a lwjgl SPHERE I am unable to see it and do not see how to texture it.

Sphere s = new Sphere();

s.draw(16f, 5, 5);
10  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-21 20:49:29
Is there a better way to subtract one image from another in libGDX?
11  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-21 20:33:03
I cannot seam to figure out any combination that works Sad Its not a good day.
12  Game Development / Newbie & Debugging Questions / Masking in libGDX on: 2012-04-21 19:57:57
Hey chaps,

I cant seam to find the equivalent of this(http://slick.javaunlimited.net/viewtopic.php?p=19140) in libGDX.

I have 3 images: stars, the a circle shape and some terrain.

I am trying to just display the terrain inside the circle so that the stars texture can be moved to give a fake pan/tilt effect.

I have been trying via the following but suspect it is the wrong technique:

      batch.begin();
      batch.draw(stars,0,0,WIDTH,HEIGHT);
      batch.draw(terrain,0,0,WIDTH,HEIGHT);
      Gdx.gl.glColorMask(false, false, true, true);
      batch.draw(mask,0,0);
      Gdx.gl.glColorMask(true, true, true, true);
      batch.end();
13  Java Game APIs & Engines / OpenGL Development / Re: Holding down keys on: 2012-04-17 12:35:33
I only just noticed these posts, sorry. Thanks for the info guys, I will implement this tonight. You are a great community.
14  Game Development / Newbie & Debugging Questions / Re: 2D game development? on: 2012-04-17 12:34:02
Here is a link to the post about the Slick book, if you offer him some money (over pay pal) i'm sure he will happily send you a digital copy.

http://www.java-gaming.org/topics/slick2d-book/26215/view.html
15  Game Development / Newbie & Debugging Questions / Re: 2D game development? on: 2012-04-17 12:32:45
There was a game made for LudumDare a year ago that would be great for you to look at the game style is exactly the same. You can find it here, the source code was released with the game.
I believe it uses the Slick2D library, there is a lot of tutorials for Slick, a member of this site recently released a book about it that may be worth a look.

http://www.ludumdare.com/compo/2009/08/30/cavernous-shooter-is-done/

Martin
16  Game Development / Newbie & Debugging Questions / Re: Buffered image? on: 2012-04-17 11:41:10
Image in the build path?
17  Java Game APIs & Engines / OpenGL Development / Re: Holding down keys on: 2012-02-27 20:45:28
my son can wait  Grin,

Works perfectly thanks chap.
18  Java Game APIs & Engines / OpenGL Development / Re: Holding down keys on: 2012-02-27 20:43:42
sweet, will give it a try now, feed my son and update.
19  Java Game APIs & Engines / OpenGL Development / Holding down keys on: 2012-02-27 20:35:01
I have an issue with the way I am having the player shoot.

I am aiming for when W,A,S,D are pressed the player shoots ONCE in that direction but with the way I have written it, there are multipul bullets fireing and the user is able to hold down the keys for rapid fire (unwanted), Im sure it could be done via bools but I dont know if there is a better way of wording the below text to get what I am after.


if (Keyboard.isKeyDown(Keyboard.KEY_W)){
         shootUp();
}

any ideas?
20  Java Game APIs & Engines / OpenGL Development / Re: real rgb values to doubles on: 2012-02-24 19:57:04
I assumed thats what you ment, the colors look a little odd. But it works, thanks again
21  Java Game APIs & Engines / OpenGL Development / Re: real rgb values to doubles on: 2012-02-24 19:30:54
Thanks chaps, I knew I was missing something obvious, been a long day! Thank again guys.
22  Java Game APIs & Engines / OpenGL Development / real rgb values to doubles on: 2012-02-24 19:05:35
Today I wrote a class that takes an image an spits it out as an array of quads with each quad matching the r,g,b,transparency and location date of each pixel of the original. (I'm rather proud of myself to be honest).
But I am stumped at something that I can't figure out.

I have the original rgb values (0-255) but need to convert them to a double that lwjgl can read. With the color4d its 0-1.

Is anyone aware of what the conversion is?
23  Java Game APIs & Engines / OpenGL Development / Re: Keep both players in shot on: 2012-01-12 23:55:21
Damm, didnt know I could use scale and translate, I should be able to use the same as I have used in a slick2D game:

g.scale(1.5f, 1.5f);
      g.translate(-x + windowWidth / 2 - 120, -y + windowHeight / 2 - 120);

...Im a numpty, thanks for your help, maby all this will make as much scene as it does to you.

24  Java Game APIs & Engines / OpenGL Development / Re: Keep both players in shot on: 2012-01-12 23:44:13
Ahhh! you little genius!

How would you focus on one player, aka, zoom in 300% and offset the cam over the player. Dont have to code if you dont want too, Im just trying to get my head round it so that I can learn and not just follow blindly

.....as I am typing I can see that my glOrtho is in my init method.....so not being updated by player movement.....shit.
25  Java Game APIs & Engines / OpenGL Development / Re: Keep both players in shot on: 2012-01-12 22:55:59
VERY quick and detailed reply! but this zooms the camera in about 1000% and puts the camera in the top right LEFT. I will fiddle with it and get back to you Cheesy

Thanks
26  Java Game APIs & Engines / OpenGL Development / Keep both players in shot on: 2012-01-12 22:17:09
If I want to keep both player in the screen at all times no matter how far apart, how can I do this with GLOrtho?

I am trying to calculate the distance between them +the player width but im not sure how to tell the camera to display that width and center (distance between players /2)

27  Game Development / Game Mechanics / Re: 2d Platformer physics on: 2012-01-12 00:04:33
Thanks ra4King,

Will try what you put in the other post, the velocity effect makes such a difference to games.

What I had until now was:
         
      if (Keyboard.isKeyDown(Keyboard.KEY_A)){
         inputX -= 1;
      }
         
      if (Keyboard.isKeyDown(Keyboard.KEY_D)){
         inputX += 1;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)){
         jump();
      }
      
      
      //Update Controls
      v.x = playerSpeed * inputX;
      a.y = GRAVITY;
      
      //Apply Controls
      x = v.x;
      
      if (y+height > screenHeight){
         System.out.println("INTERSECTION ON Y");
         v.y = 0;
         y = screenHeight-height;
      }
      else{
         v.y += a.y;
         y += v.y;
      }


p.s V and A in my code are DIRTY!, they are classes that just contain:


public class A {
   public float x;
   public float y;
}
28  Game Development / Game Mechanics / 2d Platformer physics on: 2012-01-11 19:55:56
Hey guys,

Im a noob here so hopefully I have posted in the right place.

I am working on a Cobalt style platformer/shooter, I watched this: http://flashpunk.net/2011/12/episode-12-moving-jumping-and-physics-for-platformers/
, its flash but I was able to convert is easily, the only thing is I cant figure out how to handle collision & gravity for the play jumping onto platforms, the for-mentioned video only talks about colliding with the bottom of the window.

The only way I could think about doing it looping trough all of my platforms and checking if the play was intersecting with one and if it was not allowing it to travel in y++ any more.
I'm sure this is a terrible approach and there is a better/best-practice approach that I am missing.

Thanks JGO-ers.

Martin
29  Game Development / Newbie & Debugging Questions / Re: Canvas or Jcomponent???? on: 2012-01-09 12:21:57

Example code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
public class MyGame implements Runnable {
    public static void main(String[] args) {
        new Thread(new MyGame()).start();
    }

    private final int WIDTH = 800, HEIGHT = 600;
   
    public void run() {
        JFrame frame = new JFrame("My game");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(WIDTH,HEIGHT);
        frame.setResizable(false);
        frame.setIgnoreRepaint(true); //IMPORTANT, MUST INCLUDE!
       
        Canvas canvas = new Canvas();
        canvas.setIgnoreRepaint(true); //IMPORTANT, MUST ALSO INCLUDE!
       frame.add(canvas);
       
        frame.setVisible(true);
       
        canvas.createBufferStrategy(2);
       
        BufferStrategy strategy = canvas.getBufferStrategy();
       
        while(isRunning) {
            update();
           
            //Must setup these do-while loops like this
           do{
                do{
                    Graphics2D g = (Graphics2D)strategy.getDrawGraphics();
                   
                    render(g);
                   
                    g.dispose();
                }while(strategy.contentsRestored());
               
                strategy.show();
            }while(strategy.contentsLost());

            //sleep
       }
    }
   
    public void update() {
        //update logic
   }
   
    public void render(Graphics2D g) {
        //render your game
   }
}

[/quote]

Thanks, was just thinking it would be good to have a canvas skeleton to keep, I really need to build up a templates folder. Maby a thread with canvas, jFrame, Slick - basicGame, ETC examples would be an idea. Ill pen something Smiley
30  Game Development / Newbie & Debugging Questions / Re: Real Time Combat Collision on: 2012-01-09 12:16:55
I have only been using java for a few months but it depends on if you are using java2D, lwjgl, lwjgl+slick, etc.

If you are using basic java2D (awt) then you just draw a rectangle around each object that you want to have collision. you can then put an if(){} to check for collision, something like:

1  
2  
3  
4  
if(playerSwordRectangle.intersects(enimyRectangle){

enimy.damage(5);
}

Dont forget to apply the same movement and rotation to the rectangle (hitbox) as you do to the player to keep everything lined up.

The same method would be used in Slick but I think you would want to use a polygon instead of a rectangle.

Im sure some of the far smarter people on here can give you more info but hopefully this will give you something to look at for now.
Pages: [1] 2
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
mrbenebob (16 views)
2013-06-19 14:55:23

BrassApparatus (25 views)
2013-06-19 08:52:37

NegativeZero (28 views)
2013-06-19 03:31:52

NegativeZero (30 views)
2013-06-19 03:24:09

Jesse_Attard (34 views)
2013-06-18 22:03:02

HeroesGraveDev (71 views)
2013-06-15 23:35:23

Vermeer (70 views)
2013-06-14 20:08:06

davedes (72 views)
2013-06-14 16:03:55

alaslipknot (64 views)
2013-06-13 07:56:31

Roquen (88 views)
2013-06-12 04:12:32
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
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!