• 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.

Archived

This topic is now archived and is closed to further replies.

Smoo

[java] Creating instances of Image vars

6 posts in this topic

Well, I''m stuck again with another graphics related question (obviously still related to my game). When I''m frolicking around on map and I wish to talk to someone, I basically need a "window" (manually made FF series looking window type of deal) so I create another class and create the window in there because I''m also going to have to interact with the window. Now here''s my problem. I still want to see the background of the map that I''m walking around on so basically what I do is snapshot of the background, send it to the class handling my dialog window and it draws a window with the appropriate text on top of it. Well that''s all fine and dandy *except* when I take a snapshot of my background (composed of the tiles, then it draws the hero on top) well my hero dissapears and the image flickers for a sec before going to the TextDialog class. Phew! Now that my ranting and raving is over, the solutions I''m looking for is this: I need to create a copy of the map (this includes the little guy running around) but obviously I run into problems since everything is a pointer in here. So that''s problem 1. Problem 2 is the flickering. Well I know it''s going to flicker since I''m basically going from the public void paint(Graphics g) of one class to another but is there some way to still not make it flicker? Smoo
0

Share this post


Link to post
Share on other sites
I''m assuming you''re double buffering. (If not, go get Java in a Nutshell, it''ll change your life. ) Instead of blasting the background from your main window to the TextDialog class, why not just draw on the back buffer graphics context directly from the TextDialog class? That should minimize flicker as well as eliminate the need to re-create the image.
0

Share this post


Link to post
Share on other sites
Sounds like an easier way to do it would have the dialogs background be transparent or semi-transpartent. I''m not sure you can to it with a java.awt.Window .Frame or .Dialog, but i know you can do it with java.awt.Image and I''m almost sure you can do it with java.awt.Component. So i would make my own CharacterDialog subclass of Component and give its constructor the appropriate methods for setting up a border and background.
0

Share this post


Link to post
Share on other sites
Are you trying to make a frame for the dialog or are you trying to "tint" the graphics behind the window? Either way, you could manually overwrite public void paint() with your own method, but that''s a massive pain in the neck. [You''d be on it for weeks.] Basically all you really need to is suppress the repaint() method to eliminate the flickering. Dang! I wish I could remember how to do this completely...
0

Share this post


Link to post
Share on other sites
Okay, well first things first, yes I am using the doublebuffering method, I''d have to be nuts otherwise


Anyhoo, getting down to business. Using a transparent background.... hrm... that sounds very interesting... There''s only one slight problem with that, I have no clue how! I''m only starting off in Java (basically had a class in it and continued on from there) so alot of this stuff I''m really learning for the first time but hey, you gotta start somewhere! If you could give me a snippet of code on how to do that it would be greatly appreciated (or if you wish to point me to an URL that would be also appreciated) but the only question I have to your solution is: won''t it still flicker?.... hrm... perhaps not since the background is still transparent. *ponder* *ponder* *think* *think* *think* ... perhaps not after all. Well, it''ll definitely be something to try.

Oh and SiCrane, thanks for the input and since I didn''t explain myself well enough, that''s basically what I had done (if I understood you correctly). Image snapShot = backgroundBuffer and dump the snapShot to textDialog class but this did cause a flicker because it had to redraw the background. I needed the snapShot image and not the backgroundBuffer because it didn''t have the hero drawn at the time. it''s basically like
public void paint()
{
switch()
{
case MOVE_DOWN:
drawBackgroundBuffer();
drawHeroPic();

case MOVE_UP:
drawBackgroundBuffer();
drawHeroPic();
...
}

drawBackgroundBuffer();
}

obviously this is just an example and not accurate but I need to have the drawBackgroundBuffer below my case statement, that''s why I wanted to create a copy of the backgroundbuffer after I drew the heropic and not want it to be a pointer.

hopefully that''ll have explained a bit more the situation.

Smoo
0

Share this post


Link to post
Share on other sites
http://java.sun.com/products/jdk/1.2/docs/api/

go there to explore all the methods an fields of any class about which you have questions. I'm not exactly sure why you are getting or what kind of flicker is going on so i will just ask if you have overrided repaint. If in your code of the class that gets painted on, a canvas perhaps, you have the method:

void repaint() {
...
}
then you overrode it. Inside you should just have a call to paint(); so that repaint won't do it's default action of clearing the screen then painting it.

as for the clearbackgrounds, the API says that instances of the java.awt.Component class are not opaque by default, I'm guessing that means transparent. So you would do something like this.

class CharacterDialog extends Component {
int Sizex, Sizey;
Image BGimage, Borderimage;
String Text;

public CharacterDialog(String s) {
setBGimage(something);
setBorder(something);
this.Text = s;
}

paint(graphics g) {
g.drawimage(BGimage);
g.drawimage(Borderimage);
g.drawString(Text); // maybe this calls a function that scrolls or animates the text
}
}

That's at least how I would go about it. Make the class in steps, first just see if you can get it to display a semitransparent image over your bg, then set a border for it, then have it display the text, then see about scrolling the text on to it.

Edited by - Jim_Ross on 2/3/00 10:50:48 PM
0

Share this post


Link to post
Share on other sites
I''ve actually used this kind of thing under Java 2 once and the key thing to remember is that you''ve got to add() the text component to your game window, otherwise it won''t show up. It has something to do witht the internal mechanism of handling components and their drawing...

Once you have added the text component you can say to the text component setLocation(int,int) that places it where you want it to show up. And setText() to set the text you want. If you are using Java 2''s Swing components e.g. JTextField you can say setBorder(someBorder) and setOpaque(false)...

After you''ve displayed the text as long as you want you can simply remove() the text component from the game window. Or if you want to recycle (= use it to show another spoken text) the once created and added text component you can just say setVisible(false) and it''ll hide itself.
0

Share this post


Link to post
Share on other sites