- Viewing Profile: Posts: LeDerpish
Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics
Community Stats
- Group Members
- Active Posts 8
- Profile Views 447
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
106
Neutral
User Tools
Contacts
LeDerpish hasn't added any contacts yet.
Latest Visitors
Posts I've Made
In Topic: Slow mouse position
09 July 2012 - 10:36 AM
Oh nvm, I just realized that letting the thread sleep for 20 ms helped... Thank you and sorry for bothering!
In Topic: Slow mouse position
09 July 2012 - 10:29 AM
Here is the full code for the "game":
[source lang="java"]import java.awt.Color;import java.awt.Graphics;import java.awt.GraphicsDevice;import java.awt.GraphicsEnvironment;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import java.awt.image.BufferStrategy;import javax.swing.JFrame;public class GameFrame extends JFrame { private static final long serialVersionUID = 1L; private GraphicsEnvironment ge; private GraphicsDevice gd; private BufferStrategy buffer; private boolean running; //Set the game to full screen and start it public static void main(String[] args) { GameFrame game = new GameFrame(); game.setFullScreen(); game.start(); } //Constructor public GameFrame() { super("Game Test"); setDefaultCloseOperation(EXIT_ON_CLOSE); ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); gd = ge.getDefaultScreenDevice(); //the game will stop running if escape is pressed addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if(event.getKeyCode() == KeyEvent.VK_ESCAPE) { running = false; } } }); } //Make the game full screen and create a buffer strategy public void setFullScreen() { setUndecorated(true); setIgnoreRepaint(true); setResizable(false); gd.setFullScreenWindow(this); createBufferStrategy(2); buffer = getBufferStrategy(); } //Main loop is here public void start() { Graphics g = null; running = true; while(running) { try { g = buffer.getDrawGraphics(); g.clearRect(0, 0, getWidth(), getHeight()); g.setColor(Color.RED); g.fillRect(getMousePosition().x, getMousePosition().y, 20, 20); if(!buffer.contentsLost()) { buffer.show(); } } finally { if(g != null) { g.dispose(); } } } System.exit(0); }}[/source]
lwjgl and Slick2D is programmed in Java, right? So there has to be some way to do it properly.
[source lang="java"]import java.awt.Color;import java.awt.Graphics;import java.awt.GraphicsDevice;import java.awt.GraphicsEnvironment;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import java.awt.image.BufferStrategy;import javax.swing.JFrame;public class GameFrame extends JFrame { private static final long serialVersionUID = 1L; private GraphicsEnvironment ge; private GraphicsDevice gd; private BufferStrategy buffer; private boolean running; //Set the game to full screen and start it public static void main(String[] args) { GameFrame game = new GameFrame(); game.setFullScreen(); game.start(); } //Constructor public GameFrame() { super("Game Test"); setDefaultCloseOperation(EXIT_ON_CLOSE); ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); gd = ge.getDefaultScreenDevice(); //the game will stop running if escape is pressed addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if(event.getKeyCode() == KeyEvent.VK_ESCAPE) { running = false; } } }); } //Make the game full screen and create a buffer strategy public void setFullScreen() { setUndecorated(true); setIgnoreRepaint(true); setResizable(false); gd.setFullScreenWindow(this); createBufferStrategy(2); buffer = getBufferStrategy(); } //Main loop is here public void start() { Graphics g = null; running = true; while(running) { try { g = buffer.getDrawGraphics(); g.clearRect(0, 0, getWidth(), getHeight()); g.setColor(Color.RED); g.fillRect(getMousePosition().x, getMousePosition().y, 20, 20); if(!buffer.contentsLost()) { buffer.show(); } } finally { if(g != null) { g.dispose(); } } } System.exit(0); }}[/source]
lwjgl and Slick2D is programmed in Java, right? So there has to be some way to do it properly.
In Topic: Display mode advice needed
07 April 2012 - 02:01 PM
Thank you very much! Will try to implement this now.
In Topic: Display mode advice needed
07 April 2012 - 10:35 AM
But how do I do that?assuming you've coded the rest of your program to be resolution-agnostic (i.e. working in normalized coordinates) it will work flawlessly.
In Topic: Display mode advice needed
06 April 2012 - 11:25 AM
Any idea on how to do this? Cuz as I said, I tried to do this by drawing everything to a buffered image which I then resized, but I get problems with mouse inputs then...And when the mode is changed you need to make sure your graphics code is flexible when it comes to resolution changes, so you can just change two variables (width and height) and update your graphics states. Normally game logic should not change, since you're normalizing coordinates, right? (between (-1, -1) and (+1, +1) regardless of the resolution).
- Home
- » Viewing Profile: Posts: LeDerpish

Find content