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; } }
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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();
|
|
|
|
|
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?
|
|
|
|
|
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.
|
|
|
|
|
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); Canvas canvas = new Canvas(); canvas.setIgnoreRepaint(true); frame.add(canvas); frame.setVisible(true); canvas.createBufferStrategy(2); BufferStrategy strategy = canvas.getBufferStrategy(); while(isRunning) { update(); do{ do{ Graphics2D g = (Graphics2D)strategy.getDrawGraphics(); render(g); g.dispose(); }while(strategy.contentsRestored()); strategy.show(); }while(strategy.contentsLost());
} } public void update() { } public void render(Graphics2D g) { } } |
[/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 
|
|
|
|
|
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.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|