• 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.
Sign in to follow this  
Followers 0
Crusable77

GRRR java errors

6 posts in this topic

I am attempting to make a pong clone but java hates me. I have these errors: Game.render() failure - check the game code, so i checked my code and i cant find anything wrong with it. now its just says in game.render() but there is no game.render(), however these are the two render methods with code in them. i have thwo others but they are empty:

public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
Image mainMenuScreen = new Image("res/MainMenu.png");
Image playButton = new Image("res/playButton.png");
Image exitButton = new Image("res/ExitButton.png");

g.drawImage(mainMenuScreen, 0,0);
g.drawImage(playButton, 500, 220);
g.drawImage(exitButton, 500, 300);
}

now i have this code in another class:

Image play = new Image("res/Play.png");
Image Paddle1 = new Image("res/Paddle.png");
Image Paddle2 = new Image("res/Paddle.png");

g.drawImage(play,0,0);
g.drawImage(Paddle1,0,200);
g.drawImage(Paddle2,620,200);


this is my Game.java class:

package MyGame;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame{
public static final String gamename = "Pong v.1";
public static final int mainmenu = 0;
public static final int play = 1;
public static final int menu = 2;
public static final int verdict = 3;

public Game(String gamename){
super(gamename);
this.addState(new MainMenu(mainmenu));
this.addState(new Play(play));
this.addState(new Menu(menu));
this.addState(new Verdict(verdict));
}

public void initStatesList(GameContainer gc) throws SlickException{
this.getState(mainmenu).init(gc, this);
this.getState(play).init(gc, this);
this.getState(menu).init(gc, this);
this.getState(verdict).init(gc, this);
this.enterState(mainmenu);
}

public static void main(String[] args) {
AppGameContainer appgc;

try{
appgc = new AppGameContainer(new Game(gamename));
appgc.setDisplayMode(680, 400, false); //Width length fullscreen
appgc.start();
}catch(SlickException e){
e.printStackTrace();
}

}
}

The screen shows up but in about 5 sec it closes.
0

Share this post


Link to post
Share on other sites
[quote]
I have these errors: Game.render() failure - check the game code
[/quote]
Is that literally the error message? Can you post the full error message, and any associated stack trace?

[quote]
The screen shows up but in about 5 sec it closes.
[/quote]
Does it appear to work for those 5 seconds? You are creating new images every frame. If these images allocate system resources (which it [url="http://slick.cokeandcode.com/javadoc/org/newdawn/slick/Image.html#destroy()"]appears to have[/url], you have a resource leak that will eventually cause your program to fail. Try moving the images into fields, and only loading them once at startup. If possible, ensure you are loading each image exactly once.
0

Share this post


Link to post
Share on other sites
Its says the time and date, but other than that it is the complete error message. And yes it works, i was trying to make it able to change the state when i click the button but it closes after 5 sec and wanted to get that fixed first. Edited by Mathew Bergen
0

Share this post


Link to post
Share on other sites
Debug the application and tell us where exactly it crashes, what line etc and also the exception it throws + the printed call stack might be helpful as well.

BTW: put your code in [CODE][/CODE] so it gets formatted, otherwise it is a pain to read.
0

Share this post


Link to post
Share on other sites
So when i press f11 the program runs and then 3 sec later is stops. i am using eclipse btw, but in the consle window it shows this:
[source lang="java"]hu Aug 23 08:03:47 PDT 2012 INFO:Slick Build #274
Thu Aug 23 08:03:47 PDT 2012 INFO:LWJGL Version: 2.8.4
Thu Aug 23 08:03:47 PDT 2012 INFO:OriginalDisplayMode: 1280 x 1024 x 24 @50Hz
Thu Aug 23 08:03:47 PDT 2012 INFO:TargetDisplayMode: 680 x 400 x 0 @0Hz
Thu Aug 23 08:03:48 PDT 2012 INFO:Starting display 680x400
Thu Aug 23 08:03:48 PDT 2012 INFO:Use Java PNG Loader = true
Thu Aug 23 08:03:48 PDT 2012 INFO:Controllers not available
Thu Aug 23 08:03:50 PDT 2012 ERROR:Resource not found: res/MainMenu.png
java.lang.RuntimeException: Resource not found: res/MainMenu.png
at org.newdawn.slick.util.ResourceLoader.getResourceAsStream(ResourceLoader.java:69)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:169)
at org.newdawn.slick.Image.<init>(Image.java:196)
at org.newdawn.slick.Image.<init>(Image.java:170)
at org.newdawn.slick.Image.<init>(Image.java:158)
at org.newdawn.slick.Image.<init>(Image.java:136)
at MyGame.MainMenu.render(MainMenu.java:18)
at org.newdawn.slick.state.StateBasedGame.render(StateBasedGame.java:199)
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:681)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:408)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:318)
at MyGame.Game.main(Game.java:36)
Thu Aug 23 08:03:50 PDT 2012 ERROR:Game.render() failure - check the game code.
org.newdawn.slick.SlickException: Game.render() failure - check the game code.
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:684)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:408)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:318)
at MyGame.Game.main(Game.java:36)
[/source]

and in the debug window it shows this:
[source lang="java"]<terminated>Game (1) [Java Application]
<terminated>MyGame.Game at localhost:48985
<terminated, exit value: 0>/usr/lib/jvm/java-6-openjdk-i386/bin/java (2012-08-23 8:03:47 AM)
[/source]
However i removed the big image and it worked. Im not sure how to set it as the background so i set it to 0,0. the image takes up the whole space. How would i set it as the background?

also im not sure how to do the grey bar sorry. Edited by Mathew Bergen
0

Share this post


Link to post
Share on other sites
You can insert formatted code using [ code ] and [ /code ] tags (without the spaces). Also note that unless you followed my earlier advice about loading images during startup, you still have a resource leak.
0

Share this post


Link to post
Share on other sites
Be careful what you put inside a draw/render loop; as stated above, you shouldn't be loading images in there.

Furthermode, it appears it can't find MainMenu.png, and throws an Exception, which leads to the top-level SlickException; that's your issue.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0