Show Posts
|
|
Pages: [1] 2
|
|
2
|
Game Development / Newbie & Debugging Questions / Flipped image doesn't rotate
|
on: 2013-06-10 18:53:46
|
Hello and today my question is why if I flip an image, this doesn't rotate? How can I rotate a flipped image? Flipped image, it doesnt' rotate. 1 2 3
| image.setRotation((float)angle); flipped = flip;
|
Not flipped image, it rotates perfectly 1 2 3
| image.setRotation((float)angle); flipped = flip; image.draw(position.getX() - camera.getX(), position.getY() - camera.getY(), scale); |
|
|
|
|
|
4
|
Game Development / Newbie & Debugging Questions / Re: Horizontal collisions
|
on: 2013-06-10 15:22:13
|
Sorry for my explanation.  Really what I want to do is "separating both collisions". I wanna say, don't mix the vertical collision with the horizontal collision. Actually they're mixed and it's very strange because every time I'm near a wall the code says "eh you're together a block then you must be on the top of this block". I don't want that the player go to the top of the tile when the player is together a wall :S I hope you understand better this explanation. My collision 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
| public class Collision { public Collision () { } public void Update(Camera camera, Player player, Level level) { for (int i = 0; i < level.getMap().length; i++) { for (int j = 0; j < level.getMap()[i].length; j++) { if (level.getMap()[i][j] != 0) Check(i, j, camera, player, level); } } } private void Check(int i, int j, Camera camera, Player player, Level level) { if (player.getPosition().getX() - camera.getX() > i * level.getBlockSize() + level.getBlockSize() - camera.getX() || player.getPosition().getY() - camera.getY() > j * level.getBlockSize() + level.getBlockSize() - camera.getY() || player.getPosition().getX() - camera.getX() + player.getPosition().getWidth() * player.getScale() < i * level.getBlockSize() - camera.getX() || player.getPosition().getY() - camera.getY() + player.getPosition().getHeight() * player.getScale() < j * level.getBlockSize() - camera.getY()) { } else { player.onFloor(j * level.getBlockSize(), camera); } } } |
OnFloor(player functon) 1 2 3 4 5 6
| public void onFloor(float j, Camera camera) { jump = ((position.getY() + position.getHeight() * scale) - camera.getY() >= j - camera.getY()); if (jump) { position.setY((j-camera.getY()) - (position.getHeight() * scale - camera.getY())); } } |
Thanks you very much @relminator for the link but I saw your post before I asked this and I didn't understand it so well :S Anyway thanks you 
|
|
|
|
|
5
|
Game Development / Newbie & Debugging Questions / Horizontal collisions
|
on: 2013-06-09 22:35:58
|
Hello guys I don't know how to check horizontal collisions on a tile map  I can check vertical collisions and they works perfectly but I don't know how to check horizontal ways. My problem is if the player is near the "tile" horizontal collision works but the player is teleported to the top of the tile. :S It's a platform game and I hope you understand what I mean
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / Re: Rotate player in relation to mouse position
|
on: 2013-04-14 11:51:23
|
Oh sorry for don't write a bigger description of my problem. Okay I've a little 2D game. Where the player can shot. So, I need rotate the "bow" in function of the mouse position. Really my problem isn't rotate the player, because I made it more or less. My problem is I can't stop the rotation. My problem is, when I move the mouse, the player rotate yes, but it stops never. So I want that when the player has rotated then stop. I don't know how to make that. Here's my code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| public void rotate(double x, double y, double cx, double cy, double n) { double dx = x - cx; double dy = y - cy; double r = Math.sqrt(dx*dx + dy*dy); double a = Math.atan2(dy, dx); a -= n / 180 * Math.PI; this.x = cx + r * Math.cos(a); this.y = cy + r * Math.sin(a); } public void render(Graphics g) { g.setColor(Color.red); g.drawLine((float)x, (float)y, (float)x2, (float)y2);
} public void update(GameContainer container) { Input input = container.getInput(); rotation = Math.atan2( input.getMouseY() - 600/2, input.getMouseX() - 800/2 ); rotate(x, y, x2, y2, rotation); } |
|
|
|
|
|
11
|
Game Development / Newbie & Debugging Questions / Expand background & Slick2D doubts
|
on: 2013-03-31 00:41:59
|
Hello, I've a problem with my background. My background is very little. So Is there some way to expand my little background when I maximize the window? Don't matter if my background will be pixelated when I expand it. I'm using Slick2D and by the by. I've a doubt with Slick2D, I don't know if I can commercialize my game made with Slick2D. So, Can I make a commercial game with Slick2D? 
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / Re: User Inputted Text
|
on: 2012-12-26 18:35:51
|
OMC, could you help me to use that ? :s I don't know how to use it... because it doesn't work on my game here. my 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
| public void drawDialog(Graphics g){ g.setColor(Color.BLACK); g.setFont(font); int i; for(i = 0; i < dialogs[i].length; i++){ if(dialogs[u][i] == null) text = ""; else text = dialogs[u][i]; if(text.equals("<name>")){ g.drawString(name+(System.currentTimeMillis()%500>250?"|":""), 15, 25+i*15); handleEvent(Event paramEvent); }else{ g.drawString(text,15,25+i*15); } } g.drawString("Press enter to continue...",600,25+i*15); enter = true; } public boolean handleEvent(Event paramEvent) { if(paramEvent.id==401) { if(paramEvent.key>=32 && paramEvent.key<=122) name+=(char)paramEvent.key; if(paramEvent.key==8 && name.length() > 0) name = name.substring(0, name.length() - 1); }
return true; } |
|
|
|
|
|
29
|
Game Development / Newbie & Debugging Questions / Dialog Box System
|
on: 2012-12-21 18:43:26
|
|
Hi guys... this is easy :s how can i make a dialog system?... I wanna say write dialogs in a text file and insert them inside the game. Actually i have a system that load the dialogs and show them at the screen but, how can i do for "dialog jumps" i.e "First" show the first ten lines of dialogs, and after you need press enter to show more lines. :S How can i do that?
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|