Search Results

Search found 266 results on 11 pages for 'slick'.

Page 2/11 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • 2D basic map system

    - by Cyril
    i'm currently coding a 2D game in Java, and I would like to have some clues on how-to build this system : the screen is moving on a grander map, for instance, the screen represent 800*600 units on a 100K*100K map. When you command your unit to go to another position, the screen move on this map AND when you move your mouse on a side or another of the screen, you move the screen on the map. Not sure that i'm clear, but we can retrieve this system in most RTS games (warcraft/starcraft for example). I'm currently using Slick 2D. Any idea ? Thanks.

    Read the article

  • Changing DisplayMode seems not to update Input&Graphic Dimension

    - by coding.mof
    I'm writing a small game using Slick and Nifty-GUI. At the program startup I set the DisplayMode using the following lines: AppGameContainer app = new ... app.setDisplayMode( 800, 600, false ); app.start(); I wrote a Nifty-ScreenController for my settings dialog in which the user can select the desired DisplayMode. When I try to set the new DisplayMode within this controller class the game window gets resized correctly but the Graphics and Input objects aren't updated accordingly. Therefore my rendering code just uses a part of the new window. I tried to set different DisplayModes in the main method to test if it's generally possible to invoke this method multiple times. It seems that changing the DisplayMode only works before I call app.start(). Furthermore I tried to update the Graphics & Input object manually but the init and setDimensions methods are package private. :( Does someone know what I'm doing wrong and how to change the DisplayMode correctly?

    Read the article

  • Texture switching with a entity system

    - by GameDev-er
    I'm using thinking of using an entity system in my game. So far I've been using Artemis with success. However, I have a question about texture switching. I read that switching textures too often is bad. So I load all the textures when the game loads like so: import org.newdawn.slick.opengl.TextureLoader; ... public HashMap<String, Texture> Textures; ... Then for each texture I do this: Texture tex = TextureLoader.getTexture("PNG", this.getClass().getResourceAsStream(texturePath)); Textures.put(textureName, tex); Then when drawing entities I do this: drawEntity() { glBindTexture(GL_TEXTURE_2D, Textures.get(entityTexture).getTextureID()); ... } Say I have 50 entities, using 10 different 3D models, each with their own texture. When the drawEntity system runs, it doesn't group by which entities use which texture. So I could be switching textures before drawing each entity! Is there a more efficient way to switch textures between entities? Or is glBindTexture() a good option?

    Read the article

  • How do I detect and handle collisions using a tile property with Slick2D?

    - by oracleCreeper
    I am trying to set up collision detection in Slick2D based on a tilemap. I currently have two layers on the maps I'm using, a background layer, and a collision layer. The collision layer has a tile with a 'blocked' property, painted over the areas the player can't walk on. I have looked through the Slick documentation, but do not understand how to read a tile property and use it as a flag for collision detection. My method of 'moving' the player is somewhat different, and might affect how collisions are handled. Instead of updating the player's location on the window, the player always stays in the same spot, updating the x and y the map is rendered at. I am working on collisions with objects by restricting the player's movement when its hitbox intersects an object's hitbox. The code for the player hitting the right side of an object, for example, would look like this: if(Player.bounds.intersects(object.bounds)&&(Player.x<=(object.x+object.width+0.5))&&Player.isMovingLeft){ isInCollision=true; level.moveMapRight(); } else if(Player.bounds.intersects(object.bounds)&&(Player.x<=(object.x+object.width+0.5))&&Player.isMovingRight){ isInCollision=true; level.moveMapRight(); } else if(Player.bounds.intersects(object.bounds)&&(Player.x<=(object.x+object.width+0.5))&&Player.isMovingUp){ isInCollision=true; level.moveMapRight(); } else if(Player.bounds.intersects(object.bounds)&&(Player.x<=(object.x+object.width+0.5))&&Player.isMovingDown){ isInCollision=true; level.moveMapRight(); } and in the level's update code: if(!Player.isInCollision) Player.manageMovementInput(map, i); However, this method still has some errors. For example, when hitting the object from the right, the player will move up and to the left, clipping through the object and becoming stuck inside its hitbox. If there is a more effective way of handling this, any advice would be greatly appreciated.

    Read the article

  • Slick2D Rendering Lots of Polygons

    - by Hazzard
    I'm writing an little isometric game using Slick. The world terrain is made up of lots of quadrilaterals. In a small world that is 128 by 128 squares, over 16,000 quadrilaterals need to be rendered. This puts my pretty powerful computer down to 30 fps. I've though about caching "chunks" of the world so only single chunks would ever need updating at a time, but I don't know how to do this, and I am sure there are other ways to optimize it besides that. Maybe I'm doing the whole thing wrong, surely fancy 3D games that run fine on my machine are more intensive than this. My question is how can I improve the FPS and am I doing something wrong? Or does it actually take that much power to render those polygons? -- Here is the source code for the render method in my game state. It iterates through a 2d array or heights and draws polygons based on the height. public void render(GameContainer container, StateBasedGame game, Graphics gfx) throws SlickException { gfx.translate(offsetX * d + container.getWidth() / 2, offsetY * d + container.getHeight() / 2); gfx.scale(d, d); for (int y = 0; y < placeholder.length; y++) {// x & y are isometric // diag for (int x = 0; x < placeholder[0].length; x++) { Polygon poly; int hor = TestState.TILE_WIDTH * (x - y);// hor and ver are orthagonal int W = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y + 1][x];//points to go off of int S = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y + 1][x + 1]; int E = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y][x + 1]; int N = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y][x]; if (placeholder[y][x] == null) { poly = new Polygon();//Create actual surface polygon poly.addPoint(-TestState.TILE_WIDTH + hor, W); poly.addPoint(hor, S + TestState.TILE_HEIGHT); poly.addPoint(TestState.TILE_WIDTH + hor, E); poly.addPoint(hor, N - TestState.TILE_HEIGHT); float z = ((float) heights[y][x + 1] - heights[y + 1][x]) / 32 + 0.5f; placeholder[y][x] = new Tile(poly, new Color(z, z, z)); //ShapeRenderer.fill(placeholder[y][x]); } if (true) {//ONLY draw tile if it's on screen gfx.setColor(placeholder[y][x].getColor()); ShapeRenderer.fill(placeholder[y][x]); //gfx.fill(placeholder[y][x]); //placeholder[y][x]. //DRAW EDGES if (y + 1 == placeholder.length) {//draw South foundation edges gfx.setColor(Color.gray); Polygon found = new Polygon(); found.addPoint(-TestState.TILE_WIDTH + hor, W); found.addPoint(hor, S + TestState.TILE_HEIGHT); found.addPoint(hor, TestState.TILE_HEIGHT * (x + y + 1)); found.addPoint(-TestState.TILE_WIDTH + hor, TestState.TILE_HEIGHT * (x + y)); gfx.fill(found); } if (x + 1 == placeholder[0].length) {//north gfx.setColor(Color.darkGray); Polygon found = new Polygon(); found.addPoint(TestState.TILE_WIDTH + hor, E); found.addPoint(hor, S + TestState.TILE_HEIGHT); found.addPoint(hor, TestState.TILE_HEIGHT * (x + y + 1)); found.addPoint(TestState.TILE_WIDTH + hor, TestState.TILE_HEIGHT * (x + y)); gfx.fill(found); }//*/ } } } }

    Read the article

  • how should I network my turn based game?

    - by ddriver1
    I'm writing a very basic turn based strategy game which allows a player to select units and attack enemy units on their turn. The game is written in Java using the slick2d library and I plan to use kyronet for the networking api. I want the game to be networked, but I do not know how I should go about it. My current idea is to connect two users together, and the first one to join the game becomes the game host, while the other becomes the client. However after reading http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/ it seems my game would be suited to a peer to peer lockstep model. Would that make programming the networking side much easier? Any suggestions on how I should structure my networking would be greatly appreciated

    Read the article

  • How to render axometric/isometric tiles that are a 2d array in logic, but inclined 45º visually?

    - by TheLima
    I am making a tile-based strategy game which i plan to have 2.5D visuals in an axometric/isometric fashion. Right now i'm programming it's logic and rendering it as a literal 2-dimensional array (perfect squares, like an isometric top-down-view). In short, i have something like this: And i want to turn it to something like this: Do i keep going on the 2d-array logic? Is it all just a change in rendering behavior, as i'm thinking it is? or 2d-array is the wrong approach for my objective and I should change before it's too late? What are the ways of doing it, anyways? How should i apply the 2.5D axometric/isometric view (45º rotation to the side, and 45º rotation upwards)?

    Read the article

  • java slick2D - problem using ScalableGame class

    - by nellykvist
    I have problem adjusting the size of the screen, using the ScalableGame class from Slick2D library. So, what I want to achieve, whenever I change display size, background should adjust to screen size, and objects (images, grahpic shapes) should fit (scale). Alright, so this is how state looks by default. I can change screen size, but images and graphic shapes does not appGameContainer = new AppGameContainer(     new ScalableGame(new AppStateController(), Settings.video.getWidth(), Settings.video.getHeight(), true) ); appGameContainer.setDisplayMode(Settings.video.getWidth(), Settings.video.getHeight(), Settings.video.isFullScreen()); appGameContainer.start(); If I assign to width/height +100, ScalableGame constructor: appGameContainer = new AppGameContainer(     new ScalableGame(new AppStateController(), Settings.video.getWidth() + 100, Settings.video.getHeight() + 100, true) ); appGameContainer.setDisplayMode(Settings.video.getWidth(), Settings.video.getHeight(), Settings.video.isFullScreen()); appGameContainer.start(); If I assign to width/height +100, to display: appGameContainer = new AppGameContainer(     new ScalableGame(new AppStateController(), Settings.video.getWidth(), Settings.video.getHeight(), true) ); appGameContainer.setDisplayMode(Settings.video.getWidth() + 100, Settings.video.getHeight() + 100, Settings.video.isFullScreen()); appGameContainer.start();

    Read the article

  • How can I make OpenGL textures scale without becoming blurry?

    - by adorablepuppy
    I'm using OpenGL through LWJGL. I have a 16x16 textured quad rendering at 16x16. When I change it's scale amount, the quad grows, then becomes blurrier as it gets larger. How can I make it scale without becoming blurry, like in Minecraft. Here is the code inside my RenderableEntity object: public void render(){ Color.white.bind(); this.spriteSheet.bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0,0); GL11.glVertex2f(this.x, this.y); GL11.glTexCoord2f(1,0); GL11.glVertex2f(getDrawingWidth(), this.y); GL11.glTexCoord2f(1,1); GL11.glVertex2f(getDrawingWidth(), getDrawingHeight()); GL11.glTexCoord2f(0,1); GL11.glVertex2f(this.x, getDrawingHeight()); GL11.glEnd(); } And here is code from my initGL method in my game class GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glClearColor(0.46f,0.46f,0.90f,1.0f); GL11.glViewport(0,0,width,height); GL11.glOrtho(0,width,height,0,1,-1); And here is the code that does the actual drawing public void start(){ initGL(800,600); init(); while(true){ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); for(int i=0;i<entities.size();i++){ ((RenderableEntity)entities.get(i)).render(); } Display.update(); Display.sync(100); if(Display.isCloseRequested()){ Display.destroy(); System.exit(0); } } }

    Read the article

  • ParticleSystem in Slick2d (with MarteEngine)

    - by Bro Kevin D.
    First of all, sorry if this sounds very newbie-ish. I'm stuck at making a ParticleSystem I made using Pedigree to work in my game. It's basically an explosion that I want to display whenever an enemy dies. The ParticleSystem has two emitters, smoke and explosion I tried putting it in my Enemy (extends Entity) class Enemy extends Entity class @Override public void update(GameContainer gc, int delta) throws SlickException { super.update(gc, delta); /** bunch of codes */ explosionSystem.update(delta); } @Override public void render(GameContainer gc, Graphics gfx) throws SlickException { super.render(gc, gfx); if(isDestroyed) { explosionSystem.render(x,y); if(explosionSystem.getEmitter(1).completed()) { this.destroy(); } } } And it does not render. I'm not sure if this is the proper way of implementing it, as I've considered creating an Entity to serve as controller for all the Enemies. Right now, I'm just adding enemies every second. So how do I render the ParticleSystem when the enemy dies? If anyone can point me to the right direction. Thank you for your time.

    Read the article

  • How to achieve a Gaussian Blur effect for shadows in LWJGL/Slick2D?

    - by user46883
    I am currently trying to implement shadows into my game, and after a lot of searching in the interwebs I came to the conclusion that drawing hard edged shadows to a low resolution pass combined with a Gaussian blur effect would fit best and make a good compromise between performance and looks - even though theyre not 100% physically accurate. Now my problem is, that I dont really know how to implement the Gaussian blur part. Its not difficult to draw shadows to a low resolutions buffer image and then stretch it which makes it more smooth, but I need to add the Gaussian blur effect. I have searched a lot on that and found some approachs for GLSL, some even here, but none of them really helped it. My game is written in Java using Slick2D/LWJGL and I would appreciate any help or approaches for an algorithm or maybe even an existing library to achieve that effect. Thanks for any help in advance.

    Read the article

  • Slick2D, Nifty GUI listeners problem

    - by Patokun
    I'm trying to get Nifty GUI to work with Slick2D. So far everything is going great, except that I can't seem to figure out how to properly interact with the GUI. I'm trying the example in the nifty manual http://sourceforge.n....0.pdf/download but it doesn't seem to entirely work. The Element controller is being called for bind(...), init(...) and onStartScreen() as it should, as I can see their println output, but the next() method isn't being called when I click on the GUI element that I assigned the controller to, nor the screen controller as no output from println is shown. What's weird is, that the player is moving, so the mouse input is working. It's supposed to be called when I click the mouse button on it from the in the XML. Here is my code: My Element controller: public class ElementController implements Controller { private Element element; @Override public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) { this.element = element; System.out.println("bind() called for element: " + element); } @Override public void init(Properties parameter, Attributes controlDefinitionAttributes) { System.out.println("init() called for element: " + element); } @Override public void onStartScreen() { System.out.println("onStartScreen() alled for element: " + element); } @Override public void onFocus(boolean getFocus) { System.out.println("onFocus() called for element: " + element + ", with: " + getFocus); } @Override public boolean inputEvent(NiftyInputEvent inputEvent) { return false; } public void next() { System.out.println("next() clicked for element: " + element); } } MyScreenController: class MyScreenController implements ScreenController { public void bind(Nifty nifty, Screen screen) {} public void onEndScreen() {} public void onStartScreen() {} public void next() { System.out.println("next() called from MyScreenController"); } } And my XML file: <?xml version="1.0" encoding="UTF-8"?> <nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://niftygui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd"> <screen id="start" controller="predaN00b.theThing.V0004.MyScreenController"> <layer childLayout="center" controller="predaN00b.theThing.V0004.ElementController"> <panel width="100px" height="100px" childLayout="vertical" backgroundColor="#ff0f"> <text font="aurulent-sans-16.fnt" color="#ffff" text="Hello World!"> <interact onClick="next()" /> </text> </panel> </layer> </screen> </nifty> My main class, in case it's needed: public class MainGameState extends BasicGame { public Nifty nifty; public MainGame() { super("Test"); } public void init(GameContainer container, StateBasedGame game) throws SlickException { nifty = new Nifty(new SlickRenderDevice(container), new NullSoundDevice(), new PlainSlickInputSystem(), new AccurateTimeProvider()); nifty.addXml("/xml/MainState.xml"); nifty.gotoScreen("start"); } public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { nifty.update(); } public void render(GameContainer container, StateBasedGame game, Graphics graphics) throws SlickException { nifty.render(false); } public static void main(String[] args) throws SlickException { AppGameContainer app = new AppGameContainer(new MainGame()); app.setAlwaysRender(true); app.setDisplayMode( 1260 , 720, false); //window size app.start(); } }

    Read the article

  • Distributing cross-platform .jar containing natives for LWJGL?

    - by Carter H
    I'm making a game in Java using Slick2d, which depends on LWJGL. I can get everything to work in my development environment, but when I export it to a .jar, it needs the natives placed in the same directory as the .jar. What I'm asking is if it's possible to package the natives for all operating systems in the .jar, and automatically use the right ones depending on what OS was detected. So, is this possible?

    Read the article

  • Slick2D - Entities and rendering

    - by Zarkopafilis
    I have been trying to create my very first game for quite a while, followed some tutorials and stuff, but I am stuck at creating my entity system. I have made a class that extends the Entity class and here it is: public class Lazer extends Entity{//Just say that it is some sort of bullet private Play p;//Play class(State) private float x; private float y; private int direction; public Lazer(Play p, float x , float y, int direction){ this.p = p; this.x = x; this.y = y; this.direction = direction; p.ent.add(this); } public int getDirection(){ return direction; //this one specifies what value will be increased (x/y) at update } public float getX(){ return x; } public float getY(){ return y; } public void setY(float y){ this.y = y; } public void setX(float x){ this.x = x; } } The class seems pretty good , after speding some hours googling what would be the right thing. Now, on my Play class. I cant figure out how to draw them. (I have added them to an arraylist) On the update method , I update the lazers based on their direction: public void moveLazers(int delta){ for(int i=0;i<ent.size();i++){ Lazer l = ent.get(i); if(l.getDirection() == 1){ l.setX(l.getX() + delta * .1f); }else if(l.getDirection() == 2){ l.setX(l.getX() - delta * .1f); }else if(l.getDirection() == 3){ l.setY(l.getY() + delta * .1f); }else if(l.getDirection() == 4){ l.setY(l.getY() - delta * .1f); } } } Now , I am stuck at the render method. Anyway , is this the correct way of doing this or do I need to change stuff? Also I need to know if collision detection needs to be in the update method. Thanks in advance ~ Teo Ntakouris

    Read the article

  • Slick2d Spritesheet showing whole image

    - by BotskoNet
    I'm trying to show a single subimage from a sprite sheet. Using slick2d SpriteSheet class, all it's doing is showing me the entire image, but scaled down to fit the cell dimensions. The image is 96x192 and should have cells of 32x32. The code: SpriteSheet spriteSheet = new SpriteSheet("images/"+file, 32, 32 ); System.out.println("Horiz Count: " + spriteSheet.getHorizontalCount()); System.out.println("Vert Count: " + spriteSheet.getVerticalCount()); System.out.println("Height: " + spriteSheet.getHeight()); System.out.println("Width: " + spriteSheet.getWidth()); System.out.println("Texture Width: " + spriteSheet.getTextureWidth()); System.out.println("Texture Height: " + spriteSheet.getTextureHeight()); Prints: Horiz Count: 3 Vert Count: 6 Height: 192 Width: 96 Texture Width: 0.75 Texture Height: 0.75 Not sure what the texture dimensions refer to, but the rest is entirely accurate. However, when I draw the icon, the entire sprite image shows scaled down to 32x32: Image image = spriteSheet.getSprite(1, 0); // a test image.bind(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0,0); GL11.glVertex2f(x,y); GL11.glTexCoord2f(1,0); GL11.glVertex2f(x+image.getWidth(),y); GL11.glTexCoord2f(1,1); GL11.glVertex2f(x+image.getWidth(),y+image.getHeight()); GL11.glTexCoord2f(0,1); GL11.glVertex2f(x,y+image.getHeight()); GL11.glEnd(); GL11.glDisable(GL11.GL_BLEND);

    Read the article

  • Collision detection - player gets stuck in platform when jumping

    - by Sun
    So I'm having some problems with my collision detection with my platformer. Take the image below as an example. When I'm running right I am unable to go through the platform, but when I hold my right key and jump, I end up going through the object as shown in the image, below is the code im using: if(shapePlatform.intersects(player.getCollisionShape())){ Vector2f vectorSide = new Vector2f(shapePlatform.getCenter()[0] - player.getCollisionShape().getCenter()[0], shapePlatform.getCenter()[1] - player.getCollisionShape().getCenter()[1]); player.setVerticleSpeed(0f); player.setJumping(false); if(vectorSide.x > 0 && !(vectorSide.y > 0)){ player.getPosition().set(player.getPosition().x-3, player.getPosition().y); }else if(vectorSide.y > 0){ player.getPosition().set(player.getPosition().x, player.getPosition().y); }else if(vectorSide.x < 0 && !(vectorSide.y > 0)){ player.getPosition().set(player.getPosition().x+3, player.getPosition().y); } } I'm basically getting the difference between the centre of the player and the centre of the colliding platform to determine which side the player is colliding with. When my player jumps and walks right on the platform he goes right through. The same can also be observed when I jump on the actual platform, should I be resetting the players y in this situation?

    Read the article

  • Using Single Image for Map in 2D Platformer

    - by Jon
    I'm fairly new to game development, and have been messing around with Slick2D. Currently, my map consists of objects that are represented as rectangles. If I wanted to use am image simlar to: How would I be able to use this image to make a level? That question is a bit vague, but like I said, I'm new to game development and am not familiar with terminology or procedures. But going along with this question, how would I also use non-rectangular objects/platforms? Thanks

    Read the article

  • How to reference or connect a variable to another class without stack overflow?

    - by SystemNetworks
    I really need to re-arrange all my functions. I created a class. All my var, booleans, int, doubles and other things. I created every new variable so they can reference it and so they don't have an error. If your asking why I never just reference my main class vars to my sub-class becuase it will give me stack overflow! When in my main class i link my sub-class. subClass s = new subClass(); Then I reference my fake variable to my real variable for example: This is my sub-class variable(I call it fake) public int x = 0; In my main class, I put it like this: s.x = x; The problem is, it does not work! Maybe this is not the right place but I cant ask any questions on stack overflow because they banned me. If I connect my main class and connect my sub-class it will give me stack overflow. How do I stop it?

    Read the article

  • How to stop reducing life? [closed]

    - by SystemNetworks
    CODE Input input = gc.getInput(); int xpos = Mouse.getX(); int ypos = Mouse.getY(); emu = "Enemy Life : " + enemyLife; Life = "Your Life Is" + life; Mousepos = "X:" + xpos + "Y:" + ypos; //test test1 = "Test INT" + test1int; if(!repeatStop) { //if this button is press, the damage will add up. When //pressed fight, it would start reducing the enemy health. if(input.isKeyPressed(Input.KEY_1)) { test1int += 1; } } if((xpos>1007 &xpos<1297)&&(ypos>881 && ypos<971)) { //Fight button if(Mouse.isButtonDown(0)){ finishTurn=true; } } //fight has started if(finishTurn==true) { //this would reduce the enemy life if(floodControl1==false) { enemyLife-=test1int; } //PROBLEM: Does not stop reducing! //the below code was not successful. It did not stop it // from reducing further. if(test1int>10) { floodControl1=true; } } QUESTION: Ok now, this is what is does. When I press the key, 1, it adds up the damage to the enemy. When I press fight, It will then start to reduce the enemy's health. Now my problem is, it kept on reducing and deducting it until negative! How do I deduct it to my desired damage (My desired damage is the one when press key 1)?

    Read the article

  • Adding a short delay between bullets

    - by Sun
    I'm having some trouble simulating bullets in my 2D shooter. I want similar mechanics to Megaman, where the user can hold down the shoot button and a continues stream of bullets are fired but with a slight delay. Currently, when the user fires a bullet in my game a get an almost laser like effect. Below is a screen shot of some bullets being fired while running and jumping. In my update method I have the following: if(gc.getInput().isKeyDown(Input.KEY_SPACE) ){ bullets.add(new Bullet(player.getPos().getX() + 30,player.getPos().getY() + 17)); } Then I simply iterate through the array list increasing its x value on each update. Moreover, pressing the shoot button (Space bar) creates multiple bullets instead of just creating one even though I am adding only one new bullet to my array list. What would be the best way to solve this problem?

    Read the article

  • How to only render part of an image in lwjgl/openGL

    - by Ephyxia
    I'm making a mining/building game in java using slick2D and I want to make it so you can only see a few blocks in any direction while you are underground. The best example I could find of what I want to do is the game miner dig deep. One way I thought of doing it would be to have a large image and just draw transparent areas on it where you need to be able too see but even if that would be an efficient method I wouldn't be sure how to do that.

    Read the article

  • How do I convert mouse co-ordinates in Slick2d java?

    - by Trycon
    I'm really new in Java and I really want to how do I convert the mouse clicks to co-ordinates in game. My game moves its images so that the camera could stay with the character. I follwed thenewboston tutorials. I have been modifying new codes for smoother gameplay. I have been searching the web for tutorials. This is one of the codes: PosGameX=MouseX+0; PosGameY=MouseY+0; I have not try this code but, I really think this would not work. The website I have visited, I think, is not good for coding. My gameplay is that when the mouse clicks on a position. It would try to get the co-ordinates(Mouse) and convert it to game co-ordinates. And I really want to know how do I make my mouse clicks to game co-ordinates? FOR MORE INFO: Searches: How Do I translate game co-ordinates? How Do I translate mouse to game co-ordinates? AND PLEASE! Do not give me algebra. I have really forgotten those.

    Read the article

  • How to load chunks of 2d map segments when player reaches a certain point?

    - by 2kan
    In my 2d platformer (made with Java and Slick2d), random maps are made by combining different segments together and displaying them one after the other. My problem is that I can't load too many segments or the game will run out of memory, so I want to load n number of segments at a time in chunks, then load the next chunk when the player comes near the end of one. I've attempted to do this for a couple of hours now, but I just can't get it to work at all. This is my chunk generation function where chunkLoad is the number of segments to load and BLOCK_WIDTH is the number of blocks/tiles each segment is across. Chunk1 and map are arrays of segments. Random r = new Random(); for(int i=0; i<chunkLoad; i++) { int id = r.nextInt(4)+2; chunk1[i] = new BlockMap("res/window/map"+id+".tmx", i*BLOCK_WIDTH); } map = chunk1; chunksLoaded++; The map is then drawn on the screen like this. tmap is a TiledMap object and each block/tile is 16 pixels wide for(int i=0; i<chunkLoad; i++) { map[i].tmap.render((i * BLOCK_WIDTH * 16) + (cameraX), 0); } I can successfully load new chunks, but I can't display them in the correct position, nor the hitboxes. Any suggestions? Thanks.

    Read the article

  • Strange Play Framework 2.2 exceptions after trying to add MySQL / slick

    - by Mike Cialowicz
    I'm working on a Play 2.2 application, and things have gone a bit south on me since I've tried adding my DB layer. Below are my build.sbt dependencies. As you can see I use mysql-connector-java and play-slick: libraryDependencies ++= Seq( jdbc, anorm, cache, "joda-time" % "joda-time" % "2.3", "mysql" % "mysql-connector-java" % "5.1.26", "com.typesafe.play" %% "play-slick" % "0.5.0.8", "com.aetrion.flickr" % "flickrapi" % "1.1" ) My application.conf has some similarly simple DB stuff in it: db.default.url="jdbc:mysql://localhost/myDb" db.default.driver="com.mysql.jdbc.Driver" db.default.user="root" db.default.pass="" This is what it looks like when my Play server starts: [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 (Server started, use Ctrl+D to stop and go back to the console...) [info] Compiling 1 Scala source to C:\bbq\cats\in\space [info] play - database [default] connected at jdbc:mysql://localhost/myDb [info] play - Application started (Dev) So, it appears that Play can connect to the MySQL DB just fine (I think). However, I get this exception when I make any request to my server: [error] p.nettyException - Exception caught in Netty java.lang.NoSuchMethodError: akka.actor.ActorSystem.dispatcher()Lscala/concurren t/ExecutionContext; at play.core.Invoker$.<init>(Invoker.scala:24) ~[play_2.10.jar:2.2.0] at play.core.Invoker$.<clinit>(Invoker.scala) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$Implicits$.defaultContext$lzycompu te(Execution.scala:7) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$Implicits$.defaultContext(Executio n.scala:6) ~[play_2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$.<init>(Execution.scala:10) ~[play _2.10.jar:2.2.0] at play.api.libs.concurrent.Execution$.<clinit>(Execution.scala) ~[play_ 2.10.jar:2.2.0] The odd thing is that the 2nd request (to the exact same URL, same controller, no changes) comes back with a different error: [error] p.nettyException - Exception caught in Netty java.lang.NoClassDefFoundError: Could not initialize class play.api.libs.concurr ent.Execution$ at play.core.server.netty.PlayDefaultUpstreamHandler.handleAction$1(Play DefaultUpstreamHandler.scala:194) ~[play_2.10.jar:2.2.0] at play.core.server.netty.PlayDefaultUpstreamHandler.messageReceived(Pla yDefaultUpstreamHandler.scala:169) ~[play_2.10.jar:2.2.0] at com.typesafe.netty.http.pipelining.HttpPipeliningHandler.messageRecei ved(HttpPipeliningHandler.java:62) ~[netty-http-pipelining.jar:na] at org.jboss.netty.handler.codec.http.HttpContentDecoder.messageReceived (HttpContentDecoder.java:108) ~[netty-3.6.5.Final.jar:na] at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:29 6) ~[netty-3.6.5.Final.jar:na] at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessage Received(FrameDecoder.java:459) ~[netty-3.6.5.Final.jar:na] The URL / controller that I'm requesting just renders a static web page and doesn't do anything of any significance. It was working just fine before I started adding my DB layer. I'm rather stuck. Any help would be greatly appreciated, thanks. I'm using Scala 2.10.2, Play 2.2.0, and MySQL Server 5.6.14.0 (community edition).

    Read the article

  • Java slick command line app?

    - by Felix
    Hello Guys, I want to make a slick java commandline app which doesnt include all the nasty "java -jar some.jar arguments" instead, I would have it work just like program -option argument like any other commandline app. I use ubuntu linux, and it would be fine if it included a bit of .sh script or anything. I know I can just create a file with java -jar program.jar and do chmod +x file, afterwards I could run i with ./file, but then how can I pass the arguments to the program ?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >