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

virtuosity

[java] image rotation

6 posts in this topic

I''ve been trying to rotate a bitmap using a SpinFilter class available on the webpage http://hplasim2.univ-lyon1.fr/c.ray/bks/java/htm/ch51.htm but I haven''t been able to display the rotated image. The code I used is as follows: Image image = getImage(getDocumentBase(),"wraith.gif"); Image filteredImage = createImage(new FilteredImageSource(image.getSource(),new SpinFilter(90.0)); I can draw the unfiltered original image with no problems but when I try to draw filteredImage, nothing is drawn. What am I doing wrong? Thanks in advance, virtuosity
0

Share this post


Link to post
Share on other sites
It''s been my recent experience with images that if it comes out blank, something along the way is null. Try making each variable individually and doing
System.out.println(var);
to see if it''s null. For example:

ImageProducer producer = image.getSource();
System.out.println(producer);
...
Image filtered = Toolkit.getDefaultTooklit().createImage(...);

Also, if those two lines are right next to each other in the source, then it''s probably that the image has not yet been fully loaded, you can use a media tracker to wait untill it''s loaded, but if you only have one image you might try

while ( image.getHeight(null) == -1) ;

before trying to get it''s source pixels. While an Image is loading it''s height & width are -1.
0

Share this post


Link to post
Share on other sites
quote:
Original post by Jim_Ross

Also, if those two lines are right next to each other in the source, then it''s probably that the image has not yet been fully loaded, you can use a media tracker to wait untill it''s loaded,


I second this. My gut feeling is your image probably hasn''t been loaded yet.

ManaSink


0

Share this post


Link to post
Share on other sites
I modified my code as follows and I was able to draw the image:
Image image = getImage(getDocumentBase(),"wraith.gif");
while ( image.getHeight(null) == -1) ;
ImageProducer producer = image.getSource();
ImageFilter filter = new SpinFilter(Math.PI/2);
ImageProducer filterProducer = new FilteredImageSource(producer,filter);
Image filteredImage = createImage(filterProducer);

I think the key thing was to make each of the variables individually. If I don''t wait for the image to load, I can still draw the image, albeit with a small delay. Thanks a lot for the suggestions Jim_Ross.
0

Share this post


Link to post
Share on other sites
Now that I can rotate images and draw them, I have another problem. What I''ve been attempting to do is to rotate an image a full 360 degrees in an animation sequence. The problem is that when I rotate the image, it seems that the center of the image doesn''t remain in the same place even though I''m drawing all the rotated images in the same location. This results in a jerky rotation animation because the center of rotation seems to jump all over the place. How can I rotate an image smoothly?

Thanks,
virtuosity
0

Share this post


Link to post
Share on other sites
I think you''ll have to change the top left corner coords every frame. For example, if the new image is 10 pixels wider than the original one then you subtract 5 from the x coord.
0

Share this post


Link to post
Share on other sites