Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Game programming questions  (Read 1410 times)
0 Members and 1 Guest are viewing this topic.
Offline svartberg

Junior Newbie





« Posted 2007-01-11 22:11:49 »

Hello there. I have made a 2d maze game recently like pacman. Im going to develop a 2d fighting game now. In my maze game i used the ImageIcon to present an image, now i wanna try the Image object instead.

I have some questions before i start to to this. I have read the great tutorial at http://www.cokeandcode.com/spaceinvaderstutorial
but still i don't understand everything. Here are my questions.

1. How do I paint some part of a big picture like a image file containing all the sprites I wanna use?

2. How does the paint() method work? I mean does the image disappear that i painted when I paint another one or can i clear the previous one and restore the background there?

3. Is the rectangle intersects technique good for collision detection between object,? or is there a better technique cause im going to do a fighting game and the pictures wont be rectangular.


Thanks // svartberg, new started game programmer.
Offline svartberg

Junior Newbie





« Reply #1 - Posted 2007-01-13 21:20:05 »

okay the first question i found the answer for, cause there is a graphics.drawImage method that paint some part of a picture to the screen.

my next question i haven't find any answer for. I know there is a repaint() method that paint the component, but does it have to paint all images like the background also, or just a specific image?

and about the third question i found out that maybe the collision detecting will work out fine, with points but im not sure how it work, I'll give it a try i guess.


Please give me suggestions and tell me how the painting works. // svartberg
Offline BloodRain

Junior Devvie





« Reply #2 - Posted 2007-01-13 22:36:33 »

You can try pixel perfect collision or you can use a bounding polygon .
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline nazrol

Innocent Bystander





« Reply #3 - Posted 2007-01-14 12:55:30 »

yes, it exist the draw method in java.. and you also can use repaint to update your graphics.. that you want update for example for every 1000 ms = 1 s.I'm also new to java game developpement.. but if you understand how to use timers, thing would become more easy for you. For example, the method paint, you place all the elements that you wish to draw and you create a global timer which calls the method repaint() every 1000/FPS (FPS = 80). This will redraw all the elements in paint().. and to control the other objects you can create another timer for example to move a block to the right every 2 s by 10 pixels.. you just add the current position in your new timer.So there are two timers, one that calls repaint() every 1000/FPS and the other one that adds the current x position.Also you can use the buffering, but as for beginner like me, i just use this style of coding in my first java game, tetris... hope this msg is useful to you
Offline rdcarvallo

Senior Devvie


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #4 - Posted 2007-01-15 16:17:15 »

About your second question:

The method repaint() asks for the scren to repaint, that is done by awt calling to the update(Graphics) method

The default update(Graphics) method clears the screen and calls to paint(Graphics), that's why in the paint(Graphics) method you draw all of your image again.

You can override the method to use some kind of double buffering and avoid flicker.

Next about painting, each time you draw a image in the graphics object you change the pixels so you cannot delete a image to restore the backgorund. If you need to repaint the backgorund you ned to draw the image again.  (But this is covered by the update() -> paint() cycle)

Hope this helps,
   
     Rafael.-






Offline JAW

Senior Devvie


Medals: 2



« Reply #5 - Posted 2007-01-15 21:37:51 »

I do recommend getting a book like. There are 2 or more Java Game Programming Books on Amazon. If you can afford it, they definetely cover some questions you have now and will have later.
Try Java 2 Game Programming by Thomas Petchel
Its more basic.

-JAW
Offline fletchergames

Senior Devvie





« Reply #6 - Posted 2007-01-15 22:01:03 »

Try Killer Java Game Programming or Developing Games in Java.  You can sometimes pick up programming books for only a couple bucks plus shipping on Amazon.com.  I haven't read the book JAW mentioned, so I can't comment upon it.

Don't try Advanced Java Game Programming or Black Art of Java Game Programming.  In general, don't try any programming book more than 2 years old unless there's no newer one available or it's a mature technology that hasn't changed much (e.g. sorting algorithms).  Developing Games in Java is an exception, but Killer Java Game Programming is better anyways.  I have both, and they each have some (not alot) of material that the other doesn't cover.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (10 views)
2014-12-23 03:34:11

rwatson462 (38 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!