• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

LeisureForce

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

119 Neutral

About LeisureForce

  • Rank
    Newbie
  1. It worked! I'm coming from Python, so I guess it's a little different. Thanks for your help!
  2. Hey all, I have been working on a username generator as some practise in java. But I have come into some issues. When I take input from the user on which function they'd like to go to, the program just stops. And how would I go about picking 2 random lines from the NameList.txt so I can pair them up to make a name. Also, can you tell me if this is the right way to go about reading/writing to my code. [source lang="java"]import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Scanner; public class UsernameGen { public Random randomNumber = new Random(); public List<String> userNames = new ArrayList<String>(); public static Scanner scanner = new Scanner(System.in); public boolean isRunning = true; public String command; public UsernameGen(){ home(); } public void home(){ System.out.println("--(A)dd a name to the list. "); System.out.println("--(G)enerate a name. "); System.out.println("--(Q)uit. "); System.out.println("Enter a command: "); command = scanner.next(); if (command == "g"){ getNames(); } if (command == "a"){ addToList(); } if (command == "q"){ isRunning = false; System.exit(0); } } public void addToList(){ String nameToAdd; System.out.println("What name would you like to add? "); nameToAdd = scanner.nextLine(); FileWriter fstream; try { fstream = new FileWriter("NameList.txt", true); BufferedWriter out = new BufferedWriter(fstream); out.write(nameToAdd); out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } home(); } public void getNames(){ try { BufferedReader in = new BufferedReader(new FileReader("NameList.txt")); String str; while ((str = in.readLine()) != null) { System.out.println(str); } in.close(); } catch (IOException e) { } home(); } public static void main(String[] argsv){ UsernameGen usng = new UsernameGen(); } }[/source] And the NameList.txt [code]Leisure Force Point Phile Cloaked Saint Death Zodiak Fiasco Undead Menacing Final Autophagy Dark Matter[/code] Thanks!
  3. [quote name='SimonForsman' timestamp='1349419263' post='4987029'] private float dx,dy; public Bullet(float dx, float dy, etc) { this.dx = dx; this.dy = dy; } [/quote] Okay, so instead of calling update when I hit space, I would do Bullet(dx, dy)?
  4. [quote name='rockstar8577' timestamp='1349404208' post='4986996'] Maybe a picture to see exactly what's wrong? [/quote] Sorry. Before: [url="http://i.imgur.com/tsy2M.png"]http://i.imgur.com/tsy2M.png[/url] After: http://i.imgur.com/DflSe.png
  5. Okay, now i've taken all of that into consideration, but I still have a few problems. Now, when I go to draw the bullet, it just turns the ship purple instead of drawing a rectangle to the screen. Here is my code. (I know that i am still drawing the rectangle only when i hit space, I'm just doing it for now). [code]import static org.lwjgl.opengl.GL11.*; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; import org.lwjgl.input.Mouse; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.*; import org.lwjgl.*; import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.TextureLoader; import org.newdawn.slick.util.ResourceLoader; public class Move { //make the screen width and height values public public int SCREENWIDTH = 640, SCREENHEIGHT = 480; private boolean isRunning = true; private Texture spaceShip; public int inx = 100; public SetShip myShip = new SetShip(); public Bullet myBullet = new Bullet(); public int x = myShip.ShipXStart; public int y = myShip.ShipYStart; public Move(){ //Set up the display try{ Display.setDisplayMode(new DisplayMode(SCREENWIDTH, SCREENHEIGHT)); Display.setTitle("Space Invaders"); Display.create(); } catch (LWJGLException e){ e.printStackTrace(); } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 640, 480, 0, 1, -1); glMatrixMode(GL_MODELVIEW); glEnable(GL_TEXTURE_2D); myShip.init(); //main game loop while (isRunning){ glClear(GL_COLOR_BUFFER_BIT); myShip.draw(); input(); Display.update(); Display.sync(60); if(Display.isCloseRequested()){ isRunning = false; Display.destroy(); System.exit(0); } } Display.destroy(); } private void input() { // TODO Auto-generated method stub if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)){ inx = -5; myShip.update(inx); } if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)){ inx = 5; myShip.update(inx); } if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)){ myBullet.update(10, 20); myBullet.draw(); } } private Texture loadTexture(String key) { // TODO Auto-generated method stub try{ return TextureLoader.getTexture("PNG", new FileInputStream(new File("img/" + key + ".png"))); } catch (FileNotFoundException e){ e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } return null; } public class SetShip{ public int ShipXStart = 100, ShipYStart = 400; //initialize the ship void init(){ //store the image in a texture //load the image try { spaceShip = TextureLoader.getTexture("PNG", new FileInputStream(new File("img/spaceship.png"))); } catch (FileNotFoundException e){ e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } } void update(int inx){ ShipXStart += inx; } void draw(){ spaceShip.bind(); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(ShipXStart, ShipYStart); glTexCoord2f(1, 0); glVertex2f(ShipXStart + 200, ShipYStart); glTexCoord2f(1, 1); glVertex2f(ShipXStart + 200, ShipYStart + 100); glTexCoord2f(0, 1); glVertex2f(ShipXStart, ShipYStart + 100); glEnd(); } } private static class Bullet{ //set up the variables public int x, y; //set the starting x and y for the bullets void update(int dx, int dy){ x += dx; y += dy; } void draw(){ glColor3f(1.0f,0f,1.0f); glBegin(GL_QUADS); glVertex2i(50, 50); glVertex2i(100, 100); glVertex2i(50, 100); glVertex2i(100, 100); glEnd(); } } public static void main(String[] args) { // TODO Auto-generated method stub new Move(); } }[/code]
  6. Thanks a ton!
  7. [quote name='DARSC0D3' timestamp='1349343094' post='4986701'] and like SimonForsman said don't use static you have noneed for this at this point. [/quote] Thanks for your help! And I only used static because eclipse was yelling at me, and it wouldn't work unless I put a static behind everything
  8. Hey all, I'm a beginner to the LWJGL framework, and cannot for the life of me figure this out. I am recreating the space invader game. I have the ship on the screen and moving, but I can't draw the bullet so that you can have more than 1 on the screen. Right now it just draws and goes forward when you push space, but stops drawing when you let go of space. And then when you hit space again, it draws from where it left off. Here is the code [code] import static org.lwjgl.opengl.GL11.*; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; import org.lwjgl.input.Mouse; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.*; import org.lwjgl.*; import org.newdawn.slick.opengl.Texture; import org.newdawn.slick.opengl.TextureLoader; import org.newdawn.slick.util.ResourceLoader; public class Move { private static Texture texture; private static Texture bull; public static int mx = 200; public static int my = 400; public static int bvelx = SetShip.x; public static int bvely = SetShip.y; public static void main(String[] args){ setUpDisplay(640,480); SetShip.init(); ShootBullet.init(); while (true){ glClear(GL_COLOR_BUFFER_BIT); SetShip.draw(); logic(); Display.update(); Display.sync(60); if(Display.isCloseRequested()){ Display.destroy(); System.exit(0); } } } private static void logic() { // TODO Auto-generated method stub if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)){ mx = -5; SetShip.update(mx); } if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)){ mx = 5; SetShip.update(mx); } if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)){ bvely = -15; ShootBullet.update(bvely); ShootBullet.draw(); } } private static void setUpDisplay(int width, int height) { // TODO Auto-generated method stub try{ Display.setDisplayMode(new DisplayMode(width, height)); Display.setTitle("Space Invaders"); Display.create(); } catch (LWJGLException e){ e.printStackTrace(); } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 640, 480, 0, 1, -1); glMatrixMode(GL_MODELVIEW); glEnable(GL_TEXTURE_2D); } private static class ShootBullet { private static int bulletx = SetShip.x, bullety = SetShip.y; static void init(){ try{ bull = TextureLoader.getTexture("PNG", new FileInputStream(new File("img/bullet.png"))); } catch (IOException e){ e.printStackTrace(); } } static void update(int by){ bullety += by; } static void draw(){ bull.bind(); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(bulletx, bullety); glTexCoord2f(1,0); glVertex2f(bulletx +50, bullety); glTexCoord2f(1,1); glVertex2f(bulletx +50, bullety+50); glTexCoord2f(0,1); glVertex2f(bulletx, bullety + 50); glEnd(); } } private static class SetShip{ public static int x = 200, y = 400; static void init() { // TODO Auto-generated method stub try{ texture = TextureLoader.getTexture("PNG", new FileInputStream(new File("img/spaceship.png"))); } catch (IOException e){ e.printStackTrace(); } } static void update(int mx){ x += mx; } static void draw() { // TODO Auto-generated method stub texture.bind(); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2f(x, y); glTexCoord2f(1,0); glVertex2f(x +200, y); glTexCoord2f(1,1); glVertex2f(x +200, y+100); glTexCoord2f(0,1); glVertex2f(x, y + 100); glEnd(); } } } [/code] And the images used (ship) http://i.imgur.com/5ZsbS.png (bullet) http://i.imgur.com/w5qIM.png Thanks in advance!