Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: 1 [2] 3
31  Game Development / Game Mechanics / Re: Braid-like time reversal on: 2012-03-02 16:23:06
Add a button for reverse time, player holds the reverse time button allowing for x amount of seconds where you control the frames and coordinates and other objects and bam it saves those, release the key and bam reverse time. To me I feel like this is an efficent way.
32  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided)[Solved] on: 2012-02-26 19:51:32
Was on vacation(Actually didn't bring my computer) just got back onto the forums, thanks for all of the responses . ra4king ah, I gotcha makes sense now thanks =).

Edit: the 2d some how cut off the g when I pasted the code onto here.
33  Game Development / Game Mechanics / Best way to forge an image from static images(Please answer...has cookies!!!!) on: 2012-02-26 17:42:03
Ok So I have static Images of a sprites Arm which I want to put a sword in its hand(dynamic image), I hear alot about reference pixels how do I set one up? I imagine that I mark an image with  a RBG value marked for reference and then find that pixel in the Image and then paint my sword at that pixel? But how do I go about doing so, and is this the right approach?
ALL help is appreciated, thanks in advance.
34  Game Development / Game Mechanics / Re: Player Character animation question on: 2012-02-06 17:23:34
Ok, I think I understand so.are you saying Instead of rotating I just get the coordinates? Regardless I still need to keep the sword in its proper position swinging, wont I have to adjust that with a dynamic rotate?
35  Game Development / Game Mechanics / Re: Player Character animation question on: 2012-02-04 07:44:15
So what do you recommended doing then? I'm a bit confused from your suggestion. And what do you mean by "Do it form out side"?.  Also rotate() doesn't work, any help with code to rotate on the fly trying to mimic movement arms up arms down etc.
36  Game Development / Game Mechanics / Re: Player Character animation question on: 2012-02-03 07:19:09
I mean do you think for adding armor treating the arms and legs ad separate images is the best way to animate, So Head and torso same image and then arms and legs are separate. This way I can create better character customization? Also  i'm having problems rotating parts of an image, what is the best way to rotate an image on an axis like say a arm that has a reference pixel for the shoulder and I want it to rotate up and down in  a half circle like basis?

SO say this is a sprite arm.
 sprite.drawImage(sp.imgArray().get(sp.getFrame()), sp.getX(), sp.getY(), this);//Monster Sprite

And the coordinates for the shoulder to rotate around is 30x 30y how can I achieve this?

37  Game Development / Game Mechanics / Player Character animation question on: 2012-02-02 07:58:30
First, question: For my player sprite, I think i'll have a static Torso and Head and then paint arms and legs which are rotateable objects, is this a good way to handle animation to look like movement eg running etc.
Also how do I handle rotations properly?
Second,  so I think i've come up with a way to add custom armor to a sprite and animate it(asking if this is efficent). 1)Get base image Torso and head 2) Draw armor Head and torso 3) draw Arms and legs, 4) Arms and legs append to the Torso and these arms and legs can rotate and move.

So is this a good way of handling these circumstances? Thanks in advance.
38  Game Development / Newbie & Debugging Questions / Re: Graphics2d Paint multiples problem on: 2012-02-02 00:42:08
WOW thank's for pointing that out no wonder I was noticing a drop in fps!! Thanks, yea i'll look into refractoring and extracts thanks for the advice =D
39  Game Development / Newbie & Debugging Questions / Re: Graphics2d Paint multiples problem on: 2012-02-01 22:36:46
I mean I just want to get clutter of code away instead of doing calling draw several different times, what's the most professional approach to doing so, i'm trying to keep this contained mostly in the sprite class instead of calling this in the Board class's paint, is this possible, thanks.
40  Game Development / Newbie & Debugging Questions / Re: Graphics2d Paint multiples problem on: 2012-02-01 21:59:42
Also, how can I combine a Rectangle + Image + drawString into a single Image? Is that possible? Currently I have to paint 3 seperate things:

  Map/Board class
 
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
@Override  
    public void paint(Graphics g) {
        super.paint(g);
             
       
       
        bg = new ImageIcon("Trees!.png").getImage();
         Rectangle r = new Rectangle(sp.getX()-20, sp.getY()-55,70,20);
        Graphics2D g2d = (Graphics2D)g;
          Graphics2D gfx= (Graphics2D)g;  
        g.drawImage(bg, 0,0,this);    
        gfx.setColor(Color.BLUE);
        gfx.fillRect(sp.getX()-20, sp.getY()-55,sp.returnHealth() ,10);//healthbar fill
        gfx.setColor(Color.RED);
        gfx.draw(r);//Health bar frame
        g.drawString(sp.getMTag(), sp.getX()-20, sp.getY()-10); //Monster Name
        g2d.drawImage(sp.imgArray().get(sp.getFrame()), sp.getX(), sp.getY(), this);//Monster Sprite
       // g2d.drawImage(spO.getImage(), spO.getX(), spO.getY(), this);
        Toolkit.getDefaultToolkit().sync();
               
        g2d.dispose();
    }


And once this gets painted I have a monster with a name above its head and a health bar, is there a more clean way to combine these 3 draws into a single image. I mean instead of painting these separately is there any way do it in one call OR am I doing this the right way( I feel that this isn't though) please correct me if I am wrong.
41  Game Development / Newbie & Debugging Questions / Re: Graphics2d Paint multiples problem on: 2012-02-01 21:54:43
Thanks!! Gotcha, after I set a color I have to draw it immediately and not setColor(...) setColor(..) draw(..)) draw(..).
42  Game Development / Newbie & Debugging Questions / Re: Graphics2d Paint multiples problem on: 2012-02-01 21:43:35
So how do I paint multiple seperate objects a different color? I'm new to Graphics g and 2d. Could use some help XD.
43  Game Development / Newbie & Debugging Questions / Graphics2d Paint multiples problem on: 2012-02-01 08:41:22
One class Sprite has :
 
1  
2  
3  
4  
5  
6  
7  
public Graphics2D myColor(Graphics x){
   
    Graphics2D p= (Graphics2D)x;
     p.setColor(Color.RED;
   
    return p;
    }

Board Class has:
 
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public void paint(Graphics g) {
        super.paint(g);
             
       
       
        bg = new ImageIcon("Trees!.png").getImage();
       
       
          Graphics2D gfx= (Graphics2D)g;  
        g.drawImage(bg, 0,0,this);    
        gfx.setColor(Color.BLUE);
     
       
       Rectangle r = new Rectangle(sp.getX()-20, sp.getY()-55,70,20);
       
       g.drawString(sp.getMTag(), sp.getX()-20, sp.getY()-10);
     
       sp.myColor(g).fillRect(sp.getX()-20, sp.getY()-55,sp.returnHealth() ,10);
     
      gfx.draw(r);
       
               
        g2d.dispose();
    }


       Why are the two seperate rectangles the same color???
    sp.myColor(g).fillRect(sp.getX()-20, sp.getY()-55,sp.returnHealth() ,10);
    gfx.draw(r);


  
44  Game Development / Game Play & Game Design / Re: Sprites and gear adding weapons etc(Repainting/Customizing live sprites) on: 2012-01-31 07:46:55
So how do I get a reference point to add layers to exactly where I want like add armor over a character, also how do I deal with different frames of animation for the armor how it looks when the player is running? I mean so far I have a static sprite and it has a frame for one motion another etc. I mean is the most logical solution to have differnt axis like a point of where an arm moves x pixels up when running and goes back down etc?

So for my base player sprite am I supposed to code specific points of the sprite that are movable? I'm REALLY new to animation and 2d/ all graphics.

45  Game Development / Game Play & Game Design / Re: Sprites and gear adding weapons etc(Repainting/Customizing live sprites) on: 2012-01-31 07:33:33
@Above interesting, so you would take all the frames and put it into a new Image? Also I see the term sprite used loosely, my game art I'd like to look like isn't tiny characters made out of tiny pixels but more polished figures that you would see in a flash game and other 2d games. Does this apply to all types of sprite art.

Recap, so you're saying create a layer of different images and pre-render and then use these separate images into one buffered image on the fly?
46  Game Development / Game Play & Game Design / Re: Sprites and gear adding weapons etc(Repainting/Customizing live sprites) on: 2012-01-31 00:27:23
Hm, yea I mean i'm just trying to grasp the whole concept of character customization etc, that sound's about right. I just need some insight technical wise, like how to go about repainting specifically pixel by pixel.
47  Game Development / Game Play & Game Design / Sprites and gear adding weapons etc(Repainting/Customizing live sprites) on: 2012-01-30 22:37:28
So, I have a sprite class I can paint my sprites make them animate move them with my arrow keys BUT now is when I want to create some serious character models for the player all in 2d, what/how logic is in creating and repaiting new images onto. For example If I have my main player  sprite how do add say, add a sword to the sprites hand and when it does a movement such as swing the sword, the new sword that the player equips is able to follow the hand and move. Also how do I go about painting armor onto the current sprite or w.e I want to it(my games custom API I made is pretty much done, I just need to understand the logic for sprite in game customization). What is the industry standard of doing this? All help is appreciated.
48  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-30 01:55:11
Alright thanks, question about the Button class.
Here's one I wrote just now that uses Java2D:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
public class Button {
    private boolean isDisabled, isPressed, isHovering;
    private String text;
    private Font font;
    private Color backgroundColor, hoverColor, pressedColor, textColor;
    private Rectangle2D.Double bounds;
   
    public Button(String text, Font font, int x, int y, int width, int height) {
        this.text = text;
        this.font = font;
        backgroundColor = Color.blue;
        hoverColor = Color.blue.darker();
        pressedColor = Color.blue.darker().darker();
        textColor = Color.black;
        bounds = new Rectangle2D.Double(x,y,width,height):
    }
   
    public void doAction() {
        //Called when clicked.
    }
   
    public void mousePressed(int button, int x, int y) {
        if(isHovering) {
            isHovering = false;
            isPressed = true;
        }
    }
   
    public void mouseReleased(int button, int x, int y) {
        if(bounds.contains(x,y) && isPressed)
            doAction();
       
        isPressed = false;
    }
   
    public void mouseMoved(int x, int y) {
        isHovering = false;
       
        if(bounds.contains(x,y))
            isHovering = true;
    }
   
    public void draw(Graphics2D g) {
        if(isDisabled)
            g.setColor(Color.darkGray);
        else if(isPressed)
            g.setColor(pressedColor);
        else if(isHovering)
            g.setColor(hoverColor);
        else
            g.setColor(backgroundColor);
        g.fill(bounds):
       
        FontMetrics fm = g.getFontMetrics(font);
        int width= fm.stringWidth(text);
        int height = fm.getHeight();
        int x = bounds.x+(bounds.width-width)/2;
        int y = bounds.y+(bounds.height+height)/2+fm.getDescent();
       
        g.setColor(textColor);
        g.drawString(text,x,y);
    }
}


I know this sounds stupid but I don't quite understand the mouse methods ><, where are we getting the input from?  And what is the int button for?
49  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-30 01:36:59
Alright thanks for the code, i'll read it over and try to understand it. So yea I guess that's what I have to learn to do is avoid Swing, and for HuDs and all GUI you would create everything from scratch like that button class?

So pretty much the only Swing Components you use are just Panels and frames just do the basics and that's it for game development for Swing*?
50  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-30 00:49:20
Not sure I understand you can you elaborate more about the custom class?
51  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-30 00:34:59
Here is what I have so far..
http://s986.photobucket.com/albums/ae348/TheArasonage/?action=view&current=GamePhoto.png
52  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-30 00:17:38
Thanks yea, that is what I meant originally(thanks ill look more into that). Also, that does bring me back to a HuD, for now I have a panel that is adhesive to the main frame which has different buttons settings and has a custom painting on the panel, but to have a real HuD like what you originally thought I wanted, which I do but I coped out with a JPanel Holding buttons on the frame. TO do this like you say how do I prioritize A panel over a panel such as a HuD by which I mean fully transparent and can still allow clicks onto the main panel the game world? For example I would idealy like a HUD that hold a Portrait of the player with Health and one with action bars, and then eventually start menus and such.
53  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-29 23:56:13
@OP
http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html
basiclly, you define different JPanels and each one draws different thing. For your case, you need two JPanels. One to hold the swing components while other do Graphics draw. Then add both of them in single JPanel that using Layout (so you can adjust their position). The single JPanel that holds these two can be added to JFrame.

Interesting I'll try this, thanks. Pretty much my game is an RPG and I want some npcs to have JLabels which pop up and i'd rather use java's built in components to do so instead of drawing rectangles and such manually.
So what you're saying is the one with Sprites and Images is on one, then the swing components etc get put on a transparent JPanel which then gets added on top of the Images one?

Also Is there better industry standard for making "Buttons" and components than what I'm doing to achieve such?
54  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-29 23:47:41
@Above, can you elaborate more please XD.
55  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-29 23:41:25
I'm trying to put JButtons and JLabels on this panel and have them being painted over the background Image bg. In this class I paint sprites and the background and this gets put onto a JFrame where other UI components are.

I want to make the image bg the absolute background image instead of the panels raw color background.  Pretty much I don't want the image bg to be painting over the other components? Is what i'm trying to achieve the wrong way of doing so?

And I thought I was overriding the paint method?

Thanks in  advance =D.
56  Game Development / Newbie & Debugging Questions / Re: JPanel Problem =/ Question(My Code Provided) on: 2012-01-29 23:25:11
Tried g2d.dispose, didnt work neither did adding the @Override. Here's the entire code for this Board Class:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
//------------
//import customframe.CustomFrame;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JComponent;
import java.util.*;
import java.io.*;


//------------
import javax.swing.JPanel;
import javax.swing.Timer;


public class Board3 extends JPanel implements ActionListener {

    private Timer timer;
    private SpriteO spO;
   private SpriteS sp;
   
    Random randomGenerator = new Random();
   monster_elixisDragon ED = new monster_elixisDragon();  
 
     public Image bg;  
    public Board3() {
         
         
        addKeyListener(new TAdapter());
        setFocusable(true);
        setBackground(Color.BLUE);
        setDoubleBuffered(true);
         setPreferredSize(new Dimension(450, 210));
          sp= new SpriteS();
   
        spO = new SpriteO();

       timer = new Timer(5, this);
     
      timer.start();
       this.add(ED.mlab);//Label I want to display
       
       repaint();  
   
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
       
        bg = new ImageIcon("Trees!.png").getImage();
        g.drawImage(bg, 0,0,this);  
        Graphics2D g2d = (Graphics2D)g;
        g2d.drawImage(sp.imgArray().get(sp.getFrame()), sp.getX(), sp.getY(), this);
        g2d.drawImage(spO.getImage(), spO.getX(), spO.getY(), this);
        Toolkit.getDefaultToolkit().sync();
        g2d.dispose();
         
    }


    public void actionPerformed(ActionEvent e) {
        sp.move();
        repaint();  
         
     
    }


    private class TAdapter extends KeyAdapter {

        public void keyReleased(KeyEvent e) {
            sp.keyReleased(e);
        }

        public void keyPressed(KeyEvent e) {
            sp.keyPressed(e);
        }
    }

}
57  Game Development / Newbie & Debugging Questions / JPanel Problem =/ Question(My Code Provided) on: 2012-01-29 21:57:26
Ok Question, I have a GameBoard class(JPanel) which allows me to ingegrate w.e maps I want and w.e sprites to be loaded onto it, then this is put onto my JFrame class. For my GameBoard Class I painted a Custom image onto the JPanel by:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public void paint(Graphics g) {
        super.paint(g);
       
        bg = new ImageIcon("Trees!.png").getImage();
        g.drawImage(bg, 0,0,null);  
   Graphics2D g2d = (Graphics2D)g;
        2d.drawImage(spO.getImage(), spO.getX(), spO.getY(), this);
       

       
       
        Toolkit.getDefaultToolkit().sync();
        g.dispose();
         
}


Question is, when I try to add a JLabel or JButton onto this GameBoard It keeps getting painted behind the Image. The reason I know this is If I don't paint an Image via commenting out g.drawImage(bg, 0,0,null);  I get a regular background (blue) and my buttons and lables are there, so how do I make this Image the standard panes image?

All Help is appreciated thanks.
58  Game Development / Game Play & Game Design / Re: UI and Customizable Characters on: 2012-01-20 17:40:18
What I mean is that, is this an acceptable way to make a UI, atm I pretty much I have  a frame which has a Panel which holds buttons which open up different menus"character screen, abilities, settings" instead of me drawing a rectangle I just used a JPanel on the bottom of the screen that Is static and whenever I add a game Panel eg board it gets painted with it.
59  Game Development / Game Play & Game Design / UI and Customizable Characters on: 2012-01-20 07:33:54
-First question, I recently stumbled on a way to create a custom JPanel(image) and custom JButtons(own images) and paint them to a JFrame which holds a  game board for painting 2dgraphics. Is this an ok way to have a UI the custom JPanel with my Custom Buttons on it?
-Second Question, what is the basic concept for character customization for sprites etc, like a basic image for a player and then being able to eqip armors and stuff, what is the logic etc behind doing so?

Thanks in advance =D.
60  Game Development / Newbie & Debugging Questions / Re: Dividing my game into classes? on: 2012-01-12 21:54:00
Lvl Class is a Jpanel object load all images here;

Main program- creates a jframe and loads a new lvlclass();

Sprite class--hold all data about the sprite coordinates etc mouse events.

etc etc, you want everything to be object orienated to be able to reuse instead of a cluster f**k program in  one class, you need to divide everything logically.

And just create threads for updating and repainting which get called when the Lvlclass gets painted to the MainFrame program.


Main Game Class- is a frame
             _
Sprite        Lvl class-panel    projectile class extends sprite class
 -                  -
 _   _            


Pretty much make it like that IMO, hope that helps.
Pages: 1 [2] 3
 
EgonOlsen (1278 views)
2018-06-10 19:43:48

EgonOlsen (1147 views)
2018-06-10 19:43:44

EgonOlsen (881 views)
2018-06-10 19:43:20

DesertCoockie (1291 views)
2018-05-13 18:23:11

nelsongames (1106 views)
2018-04-24 18:15:36

nelsongames (1337 views)
2018-04-24 18:14:32

ivj94 (2077 views)
2018-03-24 14:47:39

ivj94 (1230 views)
2018-03-24 14:46:31

ivj94 (2188 views)
2018-03-24 14:43:53

Solater (796 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!