Lane Spangler

  • Content count

  • Joined

  • Last visited

Community Reputation

114 Neutral

About Lane Spangler

  • Rank
  1. Scaling game to different resolutions (LWJGL)

    Ok, I fixed it. The issue was that I was using the current resolution to position game objects instead of the 1920x1080 resolution. So for example I would do [CODE] Paddle P1 = new Paddle(0, Display.getDisplayMode().getHeight()/2); [/CODE] \ When I should be doing [CODE] Paddle P1 = new Paddle(0, 540); [/CODE]
  2. Scaling game to different resolutions (LWJGL)

    I thought this as well. When I do that it does achieve the desired effect except the game no longer fits the game window. For example, in a 1024x576 window using [color=#000000]GL11[/color][color=#666600].[/color][color=#000000]glOrtho[/color][color=#666600]([/color][color=#006666]0.0D[/color][color=#666600],[/color][color=#000000] [/color][color=#006666]1920.0D[/color][color=#666600],[/color][color=#000000] [/color][color=#006666]0.0D[/color][color=#666600],[/color][color=#000000] [/color][color=#006666]1080.0D[/color][color=#666600],[/color][color=#000000] [/color][color=#006666]1.0D[/color][color=#666600],[/color][color=#000000] [/color][color=#666600]-[/color][color=#006666]1.0D[/color][color=#666600]);[/color] The game is fit to roughly the bottom left corner of the window. It seems to have scaled correctly at least.
  3. I have made a pong clone in java using the LWJGL game library. I am not sure how to make it so the game plays the same way in different resolutions. It is kind of hard to explain. I made the game based on a 1920x1080 resolution. When I change the resolution the paddle and ball and everything remains the same size in pixels. So in a lower resolution you are playing in an extremely small space and the paddles and the ball are huge. This is the code that I use to set up the display and stuff: From main class: [CODE] package; import java.awt.Dimension; import java.awt.Toolkit; import org.lwjgl.LWJGLException; import org.lwjgl.Sys; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; public class main { static boolean running = true; int fps; long lastFPS; int currentDelta; static long lastFrame; public void start() { game game = new game(); Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screensize = toolkit.getScreenSize(); System.out.println(screensize); game.xRes = (int) screensize.getWidth(); game.yRes = (int) screensize.getHeight(); try { setDisplayMode(game.xRes, game.yRes, false); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } game.OnInit(); this.lastFPS = getTime(); while ((!Display.isCloseRequested()) && (running)) { currentDelta = getDelta(); game.OnEvent(currentDelta); game.OnUpdate(currentDelta); updateFPS(); game.OnRender(); Display.update(); Display.sync(120); } Display.destroy(); } public void setDisplayMode(int width, int height, boolean fullscreen) { if ((Display.getDisplayMode().getWidth() == width) && (Display.getDisplayMode().getHeight() == height) && (Display.isFullscreen() == fullscreen)) { return; } try { DisplayMode targetDisplayMode = null; if (fullscreen) { DisplayMode[] modes = Display.getAvailableDisplayModes(); int freq = 0; for (int i = 0; i < modes.length; i++) { DisplayMode current = modes[i]; if ((current.getWidth() == width) && (current.getHeight() == height)) { if (((targetDisplayMode == null) || (current.getFrequency() >= freq)) && ( (targetDisplayMode == null) || (current.getBitsPerPixel() > targetDisplayMode.getBitsPerPixel()))) { targetDisplayMode = current; freq = targetDisplayMode.getFrequency(); } if ((current.getBitsPerPixel() != Display.getDesktopDisplayMode().getBitsPerPixel()) || (current.getFrequency() != Display.getDesktopDisplayMode().getFrequency())) continue; targetDisplayMode = current; break; } } } else { targetDisplayMode = new DisplayMode(width, height); } if (targetDisplayMode == null) { System.out.println("Failed to find value mode: " + width + "x" + height + " fs=" + fullscreen); return; } Display.setDisplayMode(targetDisplayMode); Display.setFullscreen(fullscreen); } catch (LWJGLException e) { System.out.println("Unable to setup mode " + width + "x" + height + " fullscreen=" + fullscreen + e); } } public static long getTime() { return Sys.getTime() * 1000L / Sys.getTimerResolution(); } public void updateFPS() { if (getTime() - this.lastFPS > 1000L) { this.fps = 0; this.lastFPS += 1000L; } this.fps += 1; } public static int getDelta() { long time = getTime(); int delta = (int)(time - lastFrame); lastFrame = time; return delta; } public static void main(String[] argv) { main display = new main(); display.start(); } } [/CODE] From game class: [CODE] package; import java.awt.Dimension; import java.awt.Toolkit; import java.util.Stack; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; public class game { static Stack<stateManager> stateStack = new Stack(); String TITLE = "Pong"; static int xRes = 0; static int yRes = 0; public static boolean lmbPressed; public static boolean rmbPressed; public void OnInit() { Display.setTitle(this.TITLE); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA , GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glLoadIdentity(); GL11.glViewport(0, 0, xRes, yRes); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glOrtho(0.0D, xRes, 0.0D, yRes, 1.0D, -1.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); textures.LoadTextures(); ChangeState(stateMenu.Instance()); } public void OnEvent(int delta) { if (Mouse.isButtonDown(0)) { lmbPressed = true; } else lmbPressed = false; if (Mouse.isButtonDown(1)) { rmbPressed = true; } else rmbPressed = false; if (!stateStack.empty()) { ((stateManager)stateStack.peek()).OnEvent(delta); } } public void OnUpdate(int delta) { if ((!stateStack.empty()) && (!((stateManager)stateStack.peek()).Paused)) { ((stateManager)stateStack.peek()).OnUpdate(delta); } } public static void OnRender() { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); if (!stateStack.empty()) { ((stateManager)stateStack.peek()).OnRender(); } } public static void OnCleanup() { while (!stateStack.empty()) { ((stateManager)stateStack.peek()).OnCleanup(); stateStack.pop(); } main.running = false; } public static void ChangeState(stateManager state) { if (!stateStack.empty()) { ((stateManager)stateStack.peek()).OnCleanup(); stateStack.pop(); } stateStack.push(state); ((stateManager)stateStack.peek()).OnInit(); } public static void PopState() { if (!stateStack.empty()) { ((stateManager)stateStack.peek()).OnCleanup(); stateStack.pop(); } if (!stateStack.empty()) { ((stateManager)stateStack.peek()).Resume(); } } public static void PushState(stateManager state) { if (!stateStack.empty()) { ((stateManager)stateStack.peek()).Pause(); } stateStack.push(state); ((stateManager)stateStack.peek()).OnInit(); } } [/CODE]
  4. How do YOU do it?

    [quote name='Munchkin9' timestamp='1330368058' post='4917084'] Hey there, Programming/game designing as a hobby is proving rather tricky. All too often things in my life get in the way of my time to program, this results in me often not finishing projects simply because I've lost my strand of thought, found some new interest and in general just can't seem to get motivated in the project again. While I've been able to reduce this a bit by properly commenting my code so that I know how everything works and what I was doing it really isn't enough. At the same time I find that the bigger the project the harder it will be to make and the more my own limited capabilities will get in the way. This all results in my getting almost nothing truly finished. Though I know this is normal to a limit, I think I've reached that limit. The obviouse solution, for me, seems to be to design and program really small games. Things that would take me one, or at most two, days to complete and would be fun and addictive but not truly mind blowing. Five minute games basically. Problem is, try as I might, I can not seem to come up with any. I know the general idea of what a small game should be like, but whenever I try to sit down and design one the game either ends up being uninteresting or too 'big'. Very quickly I notice I'm adding extra 'small', fun features left and right. These 'small' features quickly accumulate though, the project gets too big, then somewhere along the line I realize that the original idea, while probably a good one, is in itself too big and I scrap the entire thing. Its like feature creep at the design process, on crack. So I'm seeking some tips from you guys. How do you design a small, quick game and get about making it without it turning into a major project? [/quote] While I will not answer your ultimate question, I may be able to help you with your problem. If you are getting lost in your code you should think about implementing a more modular game engine. For example in my java game engine each game state is represented with a separate class, as well as each object that requires drawing such as a tile, block, wall, character etc. Sometime I find myself doing too much in one class and the code becomes very hard to read. I don't really think that making small games is a satisfactory solution because even games that most would consider small require an amount of persistance on the part of the programmer.
  5. Idea Wanted For Isometric Game

    [quote name='Stormynature' timestamp='1331343478' post='4920818'] [quote name='Lane Spangler' timestamp='1331328000' post='4920761'] So essentially it would be like a roguelike where you always lose in the end and you start out by building a fort and you have to mantain it, defend it, and lead raids? [/quote] Not necessarily a loss. Sieges invariably are won by defeating the invading army through some means or alternatively outlasting their own supplies. By utilising resources carefully and the careful use of raids what you can build the game into basically an "How to win the Alamo". Hard but doable. Though I must admit was thinking more a fortified city as opposed to a fort...but that could also be a scaling set of levels -- each level you start with a defense againt an invading army until defeated then you fall back to the next larger defence point until you have reached a point where you can fight back. The more successful your defences the less overwhelming the army becomes. Mini levels like timed games i.e. the longer you hold a defence of a pass the more resources you can send back, as well implement a scorched earth policy. Another level could be the destruction of bridges and fortification of river fjords. Another could be the limited choice given to either save people, or food, or metals etc i.e. which resource becomes vital to the war effort at that time. The end result of the game could be as you said a crushing loss, but it could also be a victory. Not sure if any games are out there like this to be honest, but I must admit the more I write on this the more subtle intricacies I can see to make this game rather fun to play. Hope the answers help [img][/img] [/quote] Thanks for taking the time to share your ideas. I think it is a good idea to make the game winnable even though I have no problem with roguelikes. As far as the city part though, I was thinking since I am spending so much time on the level editor, it would make sense to incorporate a limited version of it into the actual game. So that's why I was thinking you would start out with just a fort and you have to build your city up in a smart way in order to survive the invasion.
  6. Idea Wanted For Isometric Game

    [quote name='Stormynature' timestamp='1331266721' post='4920576'] RTS suggestion. A fortified town surrounded by a large army. The town is backed up against an ocean thus supplies can get through. Resources are used to bolster defenses, feed the population, build new buildings, Salvaging of existing buildings that serve no purpose etc. Raids could be launched via the gate or alternatively dropped off by a ship along the coastline and attack from behind to either wreck or steal supplies, take out small groups etc. Resource management could be controlled via the ships i.e. you order what materials or personnel you need paying with them via internal taxes or war booty as well inhouse industries such as fishing etc. [/quote] So essentially it would be like a roguelike where you always lose in the end and you start out by building a fort and you have to mantain it, defend it, and lead raids?
  7. I am working on a level editor for an isometric game so the idea can be anything as long as it is isometric tile based. Here is what i have planned and accomplished for the editor: Finished: Tiles- Grass Paved Road Paved road with lines Raised Tiles: Tall Grass Sidewalk Tile select and fill tool Wall tool for placing and deleting walls Planned: Any tile or wall type required for idea Object placement tool Multi-floor and roofs Possible: Diagonal wall placement Partial tiles So the fame could be anything that could make use of this kind of level. For example a fantasy action RPG or a zombie survival game or maybe a RTS Edit heres a screenshot from the editor: