Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
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  
  Components or paint?  (Read 471 times)
0 Members and 1 Guest are viewing this topic.
Offline zhengdk

Senior Newbie





« Posted 2014-05-12 10:10:28 »

I know that the title is ambiguous. I will explain.

So for game graphics, I know 2 ways to draw the whole thing.
1. You may use JPanel, JLabel or other components to draw your UI even your in-game things.
2. You may define your own class, own variable and override the paintComponent() method in you canvas class to draw your variables.

Game are of many types, action, strategy, shooting, chess, board game etc.. Some game can purely use the 2nd way of drawing, but I don't think all game fits (especially in board game, the position of many components are fixed).

So my question is, which is better in different type of games. Which is better for different part of the game (item bar, score label, menu). Then the advantages and the disadvantages of these 2.
Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2014-05-12 11:46:16 »

Never, ever use the first way to create games. Its slow and just... gross to use code designed to create UIs to make games with.

Online Drenius
« Reply #2 - Posted 2014-05-12 14:29:37 »

@opiop65: Ya, thats true. Did that without better knowing once and it was absolutely not a good idea.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zhengdk

Senior Newbie





« Reply #3 - Posted 2014-05-13 02:54:41 »

I made a tetris game. On the left is the game zone, I used a JPanel as the canvas. On the right there are score pane, "next block pane" and else. The main frame is fixed, I don't need to refresh the other-than-Canvas-parts so often. I reckoned it would be OK to use components there.

Never, ever use the first way to create games. Its slow and just... gross to use code designed to create UIs to make games with.
Online BurntPizza

« JGO Bitwise Duke »


Medals: 273
Exp: 5 years



« Reply #4 - Posted 2014-05-13 02:57:52 »

I made a tetris game. On the left is the game zone, I used a JPanel as the canvas. On the right there are score pane, "next block pane" and else. The main frame is fixed, I don't need to refresh the other-than-Canvas-parts so often. I reckoned it would be OK to use components there.

Never, ever use the first way to create games. Its slow and just... gross to use code designed to create UIs to make games with.

Yeah, that's fine. That's called a gui, and you should use gui components to build it, that's what they're for.
What I think opiop said not to do (which you shouldn't) is to draw to a JPanel or something and move the JPanel around the screen instead of simply drawing an image moving in a canvas.
In short: you're doing it right.
Offline zhengdk

Senior Newbie





« Reply #5 - Posted 2014-05-13 03:07:49 »

Imaging a board game, the game zone is not independent in the framework. But many parts are fixed, sometimes you even need to move these parts around in gui designing.
Online BurntPizza

« JGO Bitwise Duke »


Medals: 273
Exp: 5 years



« Reply #6 - Posted 2014-05-13 03:10:46 »

Imaging a board game, the game zone is not independent in the framework. But many parts are fixed, sometimes you even need to move these parts around in gui designing.

Sure, there are even drag and drop editors for many gui frameworks (including swing, netbeans has one built in), but that's the gui. For the actual game's graphics, besides maybe a HUD, you want to render that all yourself. There are of course also many ways of doing that rendering too.
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.

PocketCrafter7 (13 views)
2014-11-28 16:25:35

PocketCrafter7 (9 views)
2014-11-28 16:25:09

PocketCrafter7 (10 views)
2014-11-28 16:24:29

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

toopeicgaming1999 (66 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!