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

Kosh

[java] Java Graphics

9 posts in this topic

Hi everyone, I am trying to program a little 2d application in java, just something that plots pixels to a screen. I want to recreate my good ol days with the spinning cubes, but I am unsure about how I should plot pixels in an efficient manner, I know about the Point2D class, but I would like to know, is there a better way of doing this. If you know anything that can help me please do tell me thanks Kosh
0

Share this post


Link to post
Share on other sites
You may want to check out the following book:

Java 2d API Graphics with Cdrom
Vincent J. Hardy
ISBN: 0130142662
Publisher: Prentice Hall
Pub. Date: August 1999
Edition Desc: BOOK & CD

Its one of the few decent books for Java and Graphics that I have found.

Also, I know you said you wanted to use 2D, but you may want to consider Java 3D as well. The example you quoted - creating spinning cubes - could be accomplished in just a few lines of code (in fact, one of the demo programs that comes with Java 3D is a mouse controlled spinning cube).
0

Share this post


Link to post
Share on other sites
I know perhaps Java3D is a better choice, but I am trying to create a rendering engine, so using someone else''s 3d engine isnt a way that I would like to proceed, therefore, 2d is only open to me

do you have any online links ? cause I dont want to buy ANOTHER java book only to find that I didnt really need it.
spent too much money to do that mistake again....

thanks
0

Share this post


Link to post
Share on other sites
Buy The Black Art of Java Programming! It uses java 1.0 but all out-of-date code is very easy to change to java 2. Yes it explains how to create 3d engine, which had constantly 60 fps, but in 300x400 applet

Time comes, time goes and I only am.
0

Share this post


Link to post
Share on other sites
ok, sorry to say this, but saying "buy this book" and "buy that book" is not what I want help with, I know I can buy this and that, but I dont want to buy another java book, I have four already, I want somewhere on the web that can help me, I have followed the advice of people before, spent over £150 on books in java and all of them have been a disappointment so therefore I wont buy another java book, cause I dont think they are worth it.

Can someone please suggest anything else other than "buy this book"

thanks.

kosh
0

Share this post


Link to post
Share on other sites
ok, sorry to say this, but saying "buy this book" and "buy that book" is not what I want help with, I know I can buy this and that, but I dont want to buy another java book, I have four already, I want somewhere on the web that can help me, I have followed the advice of people before, spent over £150 on books in java and all of them have been a disappointment so therefore I wont buy another java book, cause I dont think they are worth it.

Can someone please suggest anything else other than "buy this book"

thanks.

kosh
0

Share this post


Link to post
Share on other sites
I have bought 4 books too, and not even single one of them were disappointment. I have Sams book 21 hours or 24 days it was the first one. Then I have little manual for Java 2 which is extremely handy because it's so quick to recollect and cheat things out from it. Then I have this Black Art book and some kind of book which is written in my mother tongue. I'm sorry, but what I have looked there are very little things on we from Java Game programming. There are ready made engines, but that wasn't what you were looking for, but if you want see one go to the JGDC home page (www.jgdc.com) and check code section, if you look enough those examples and then put all you have found together I'll bet that you have ready 3d engine ready before you can say cheese! At least that would be the way that I'd do it

Time comes, time goes and I only am.

Edited by - Arch@on on 3/12/00 12:27:19 PM
0

Share this post


Link to post
Share on other sites
Let me get this straight, you want to plot pixels to a screen? If by a pixel you mean a real pixel of size 1x1, then maybe you should familiarize yourself to the usage of an animated MemoryImage source. That technique is largely used in Java demos and should be quite fast (at least it is much faster than plotting hundreds/thousands of points through Graphics object).

The downside is that you''ll have to calculate all the transformations by yourself (calculate the screen x,y coordinates from world coordinates).

The technique is simply:
1) During initialisation create an integer array of size (screen width x height) and use that array to create an java.awt.image.MemoryImageSource and create an image from that. Set the memory image to be animated by calling the setAnimated(true) on it.


int[] pixels = new int[ width * height ];
MemoryImageSource memImageSrc =
new MemoryImageSource(
width,
height,
ColorModel.getRGBdefault(),
pixels,
0,
width );
memImageSrc.setAnimated( true );
Image theWholeScreen =
Toolkit.getDefaultToolkit().createImage(
memImageSrc );


2) You modify the individual pixels by setting the integer arrays values to wanted pixel values.


// Set pixel at x,y coordinates to red
pixels[ x + y * width ] = 0x00FF0000;


3) You tell the memory image source you have changed the pixels in the memory. Note: This should really just update the changed area, not the whole area as I have done here.


memImageSrc.newPixels( 0, 0, width, height );


4) You paint the image representing the whole screen to the graphics (in paint(Graphics g) or some other suitable way).


grfx.drawImage(
theWholeScreen,
0,
0,
null );


Hopefully this helps you getting started...
0

Share this post


Link to post
Share on other sites
There is also a good technique in "The Black Art of Java Game Programming" in which you use Shapes to plot "3D" images to the screen. Your spinning cube would just be 6 Shape objects and you would do the transformations and surface hiding manually. It is a good book, if you don't want to buy it, just go to the book store and thumb through it.

Also Kosh, your post about "spinning cubes" and "2d application" seem to be a bit contrary.

Edited by - Jim_Ross on 3/14/00 10:09:44 AM
0

Share this post


Link to post
Share on other sites