Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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]
1  Game Development / Newbie & Debugging Questions / Re: How to make sprites in Java possibly using Arrays? on: 2014-01-14 23:37:46
@ Lcass....

Could you give me code above that I could actually run? Its ok explaining things in code but theres no example to run for me to understand..... Thanks for trying though. You must be good no doubts, i can kind of understand it but if i cant see what its doing im never gunna learn from ur efforts of explaining......
2  Game Development / Newbie & Debugging Questions / Adding More Animations on a Single JFrame on: 2014-01-13 18:47:05
No one could help me on another post but here we go:

If anyone can help with this code I basically started with adding the Spooky class like I say then went to the top of the code and got stuck on the getContentPane which isn't allowing me to add 2 lines of that to add 2 of the shapes to animated...

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  
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JFrame;

public class test extends JFrame {

   public Gunman g = new Gunman();
   public Spooky j = new Spooky();

   public static void main(String[] args) {
      test t = new test();
      t.setSize(800, 600);
      t.setVisible(true);
      t.getContentPane().add(t.g);
      t.setBackground(Color.DARK_GRAY);

      while (true) {
         t.g.x = t.g.x + 1;
         t.g.y = t.g.y + 1;
         t.repaint();
         try {
            Thread.sleep(50);
         } catch (InterruptedException e) {
         }
      }
   }

   public void paintComponent(Graphics g) {
      g.clearRect(0, 0, 800, 600);
   }
}

class Gunman extends JComponent {

   // private static final long serialVersionUID = 1L;
   public int x = 20;
   public int y = 20;
   public int width = 20;
   public int height = 20;

   public void paintComponent(Graphics g) {
      g.setColor(Color.blue);
      g.fillRect(x, y, width, height);
   }
}
   class Spooky extends JComponent {
      public int x = 30;
      public int y = 30;
      public int width = 40;
      public int height = 50;

      public void paintComponent(Graphics g) {
         g.setColor(Color.RED);
         g.fillOval(x, y, width, height);
      }
   }


---- ORIGINAL CODE ----

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  
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JFrame;

public class Test extends JFrame {

    public Gunman g = new Gunman();

    public static void main( String[] args ) {
        Test t = new Test();
        t.setSize( 800, 600 );
        t.setVisible( true );
        t.getContentPane().add( t.g );

        while ( true ) {
            t.g.x = t.g.x + 1;
            t.g.y = t.g.y + 1;
            t.repaint();
            try {
                Thread.sleep( 100 );
            } catch ( InterruptedException e ) {
            }
        }
    }

    public void paintComponent( Graphics g ) {
        g.clearRect( 0, 0, 800, 600 );
    }
}


class Gunman extends JComponent {

    private static final long serialVersionUID = 1L;
    public int x = 10;
    public int y = 10;
    public int width = 8;
    public int height = 10;

    public void paintComponent( Graphics g ) {
        g.setColor( Color.red );
        g.fillRect( x, y, width, height );
    }
}


^^ You should see where I was going with it

Apologies for posting simular on another topic I made but I didn't get any response on that reply. I've learned a hell of a lot though from you people over the last week with helpful links, I'm glad I've joined!  Smiley
3  Game Development / Newbie & Debugging Questions / Slick2D Test Files Not Working / Compiling on: 2014-01-13 15:35:33
I have tried google but no luck, often I want a break from learning things from scratch and have a crack at Slick2D library, I want to look and load the test files but when I try to load something like... AnimationTest.Java it says:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

   at slick.tutorial.AnimationTest.main(AnimationTest.java:100)

Which is this line:

100: public static void main(String[] argv) {

I've tried alsorts but this should ideally work? it has the main method, no other errors. I just want to be able to load up examples and learn from it.

Thanks
4  Game Development / Newbie & Debugging Questions / Re: How many ways could a game be developed? on: 2014-01-13 13:35:18
Great thanks..

I've noticed today that for keyboard input moving lets say a g.drawRect() on JFrame, there are many ways of using the key class to do this?

1. How many ways from the top of your head do you think you could do this? (This will also help me on the research side to programming in java)

Also, 2. How should I start out with programming a small game like pong/breakout, would it be best if I just stick to making it in one class first?

If someone could answer these 2 questions especially the 1st one that'd be excellent personally.
5  Game Development / Newbie & Debugging Questions / How many ways could a game be developed? on: 2014-01-13 12:58:06
Sorry if this is a stupid question, I've been away from programming for a while and just got back into it.

I'm interested is there more than one way a game like pong for example could be programmed? or would it always be near enough 95% the same code (methods, libraries etc).. Excluding named variables of course hence the 95% . Lets say if it was a pong to be developed using JFrame...

Basically would there be a number of ways to code it to do that job of the classic pong? or even space invaders, tetris etc

I'd be interested to hear some feedback on this from the pros to help with my learning & confidence carrying on

I've also posted this question before in another java forum (not java gaming) but that was more for software, I'm interested to see what the experts have to say on here...

Thanks
6  Game Development / Newbie & Debugging Questions / Re: How to make sprites in Java possibly using Arrays? on: 2014-01-12 20:22:57
Thanks for the replys everyone, I've been spending the last few days on these links you've gave me and I'm benefiting a lot - this forums ace!

Btw, could someone please help me with my code I've pasted above and possibly answer that question, maybe tweak the code and explain how I'd have 2 animated dots/square in different colors moving, this way I'd be understanding on move on to adding like a bat to bounce off....

Thanks...
7  Game Development / Newbie & Debugging Questions / Re: How to make sprites in Java possibly using Arrays? on: 2014-01-10 00:42:58
---- ORIGINAL CODE COPIED FROM ANOTHER FORUM --- (HOPEFULLY YOU CAN SEE WHERE IVE GONE WITH IT......

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  
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JFrame;

public class Test extends JFrame {

    public Gunman g = new Gunman();

    public static void main( String[] args ) {
        Test t = new Test();
        t.setSize( 800, 600 );
        t.setVisible( true );
        t.getContentPane().add( t.g );

        while ( true ) {
            t.g.x = t.g.x + 1;
            t.g.y = t.g.y + 1;
            t.repaint();
            try {
                Thread.sleep( 100 );
            } catch ( InterruptedException e ) {
            }
        }
    }

    public void paintComponent( Graphics g ) {
        g.clearRect( 0, 0, 800, 600 );
    }
}


class Gunman extends JComponent {

    private static final long serialVersionUID = 1L;
    public int x = 10;
    public int y = 10;
    public int width = 8;
    public int height = 10;

    public void paintComponent( Graphics g ) {
        g.setColor( Color.red );
        g.fillRect( x, y, width, height );
    }
}
8  Game Development / Newbie & Debugging Questions / Re: How to make sprites in Java possibly using Arrays? on: 2014-01-10 00:41:38
Thanks for the replys, I'm starting to understand apart from the last post made - the code looks familiar but how would I put this to action so I can how it works on something like JFrame?

Here is some code I've found on another forum, basically it was 1 small moving blue box animated and I've added a class section called Spooky to add my own to render/animate with that but I cant seem to make them fit together because of getContentPane and adding them twice if this makes sense, How could I make 2 different shapes move around the screen differently...

I'm getting there slowly but very frustrating, I'm spending hours learning and feels I'm not getting anywhere sometimes. If anyone can help with this code I basically started with adding the Spooky class like I say then went to the top of the code and got stuck on the getContentPane which isn't allowing me to add 2 lines of that to add 2 of the shapes to animated

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  
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JFrame;

public class test extends JFrame {

   public Gunman g = new Gunman();
   public Spooky j = new Spooky();

   public static void main(String[] args) {
      test t = new test();
      t.setSize(800, 600);
      t.setVisible(true);
      t.getContentPane().add(t.g);
      t.setBackground(Color.DARK_GRAY);

      while (true) {
         t.g.x = t.g.x + 1;
         t.g.y = t.g.y + 1;
         t.repaint();
         try {
            Thread.sleep(50);
         } catch (InterruptedException e) {
         }
      }
   }

   public void paintComponent(Graphics g) {
      g.clearRect(0, 0, 800, 600);
   }
}

class Gunman extends JComponent {

   // private static final long serialVersionUID = 1L;
   public int x = 20;
   public int y = 20;
   public int width = 20;
   public int height = 20;

   public void paintComponent(Graphics g) {
      g.setColor(Color.blue);
      g.fillRect(x, y, width, height);
   }
}
   class Spooky extends JComponent {
      public int x = 30;
      public int y = 30;
      public int width = 40;
      public int height = 50;

      public void paintComponent(Graphics g) {
         g.setColor(Color.RED);
         g.fillOval(x, y, width, height);
      }
   }
9  Game Development / Newbie & Debugging Questions / Re: How to make sprites in Java possibly using Arrays? on: 2014-01-09 00:58:28
Thanks for the reply

I checked out your games source 'Ringvibe', I must say I'm pretty baffled... There seems to be more maths than methods, this is exactly how I want to learn to program properly other than just external files chucked in using methods and a few keywords if this makes sense... How do you go about learning this kind way of using all this math to create things of the screen? Sorry if this comes across lame but I know what I mean in my head when I'm viewing all the numbers n what not on the source code, normally when you view a game source you just see methods of game/sound java / third party API's

Please put me in the right direction, here is something I've just copied quick but how would I draw this as a sprite....

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
      private final String[] levels = new String[] {"66111111111111"+
         "36a21111b11111"+
         "00000111000111"+
         "11111711111111"+
         "1111577f11111d"+
         "77770000111110"+
         "1e11000011c110"+
         "10000000000110"+
         "10000000000110"+
         "10000000000110"+
         "10000000000110"+
         "44444444444444",
10  Game Development / Newbie & Debugging Questions / How to make sprites in Java possibly using Arrays? on: 2014-01-08 17:24:09
Sorry if this has been asked numerous times, I'm quiet new to java and I don't know exactly what to search for when it comes to this subject.

But please, if someone could give me a basic example on how to make a sprite using an array. Similar to how they do it on them Java4k Games. There is a game by Notch(Minecraft) where he did a lemming type clone and did something using multiple arrays when it came to animation. But if I start with 'still' arrays for now and work from that. I have been trying to learn off source code like notch's game and other programmers but when I'm copying bits and bobs I get lost and frustrated.

So if anyone could just give me some demo Java Applet/Application code to display, lets say, a smiley face or a green blob if you dont have time

I hope I make sense hear.. I really want to have a go at doing sprites the old fashioned way rather than using photoshop and importing images.

Thanks
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
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!