Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
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
1  Game Development / Newbie & Debugging Questions / Re: Theoretical Solitaire Design Questions :) on: 2013-03-03 09:25:32
Hey Nerb, thank you for taking the time to write me that detailed response, you are a legend! I actually learned a few things by your post, one of those 'click' moments, which is awesome!  Grin


2  Game Development / Newbie & Debugging Questions / Re: Theoretical Solitaire Design Questions :) on: 2013-03-02 01:09:13
Not sure why my drag controller class is working Sad If someone could help me out that would be AWESOME!!!  Grin

(made a test project to play around with the drag controller class)

EDIT: Sorry for the double post!

MAIN SOLITAIRE 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  
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Solitaire extends JPanel {

   private static final long serialVersionUID = 1L;
   
   private final static int GAME_WIDTH = 900;
   private final static int GAME_HEIGHT = GAME_WIDTH / 16 * 9;
   
   private JFrame frame;
   private Card card;
   
   private ArrayList<Card> cards = new ArrayList<Card>();
   
   public Solitaire() {
      this.setPreferredSize(new Dimension(GAME_WIDTH, GAME_HEIGHT));
      this.setFocusable(true);
      this.setVisible(true);
     
      frame = new JFrame();
     
      card = new Card();
   }
   
   protected void paintComponent(Graphics g) {
      super.paintComponent(g);
      Graphics2D g2d = (Graphics2D)g;
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     
      card.draw(g2d);
   }
   
   public static void main(String[] args) {
      Solitaire game = new Solitaire();

      game.frame.setResizable(false);
      game.frame.add(game);
      game.frame.pack();
      game.frame.setLocationRelativeTo(null);
      game.frame.setVisible(true);
      game.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
     
   }

}


CARD 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  
package com.eternalgames.javasolitaire;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;

import javax.swing.JComponent;

public class Card extends JComponent{
   
   private static final long serialVersionUID = 1L;

   private DragController dragController;
   
   private final int CARD_WIDTH = 100;
   private final int CARD_HEIGHT = 150;
   
   public int x = 0;
   public int y = 0;
   
   public Card() {
      dragController = new DragController(this);
   }
   
   public void draw(Graphics2D g2d) {
      g2d.setColor(Color.red);
      g2d.fillRect(x, y, CARD_WIDTH, CARD_HEIGHT);
   }

   public void setCardPos(int x, int y) {
      this.x = x;
      this.y = y;
   }
   
   @Override
   public Dimension getSize() {
      return new Dimension(CARD_WIDTH, CARD_HEIGHT);
   }
}


DRAG CONTROLLER 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  
package com.eternalgames.javasolitaire;

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;

import javax.swing.event.MouseInputAdapter;

public class DragController extends MouseInputAdapter {
   
   private Card card;
   
   private Point offset = new Point();
   private boolean dragging = false;
   
   public DragController(Card card) {
      this.card = card;
     
      card.addMouseListener(this);
      card.addMouseMotionListener(this);
   }

   public void mousePressed(MouseEvent e) {
      Point p = e.getPoint();
      Rectangle r = new Rectangle(card.getSize());
     
      if (r.contains(p)) {
         offset.x = p.x - r.x;
         offset.y = p.y - r.y;
         dragging = true;
      }
   }
   
   public void mouseReleased(MouseEvent e) {
      dragging = false;
   }
   
   public void mouseDragged(MouseEvent e) {
      if (dragging) {
         int x = e.getX() - offset.x;
         int y = e.getY() - offset.y;
         card.setCardPos(x, y);
      }
   }
}
3  Game Development / Newbie & Debugging Questions / Re: Theoretical Solitaire Design Questions :) on: 2013-03-01 08:58:10
I'd hold each card in a stack in an array. And for each card within the stack, calculate its 'visible/clickable extent', i.e. the top of the card poking out from within the stack, which could be stored as a Rectangle (this may be constant, or adjust dependant on the number of cards in the stack).

When you click on a stack, check which card's visible extent contains the click, by iterating through the cards in the stack array.

You could then use its array index to handle all cards above it. I.e. if a stack contains 13 cards, where stack[0] is the card at the bottom of the stack, and stack[12] is the topmost card, if your click detection determined you've clicked on stack[8], then you apply the drag event to all cards from stack[8] through to stack[12].



Yeah man, I was thinking that too (the clickable top rectangle), it seems like the most logical solution. You could handle the clickable areas sort of like tabs within the stack group, and like you said, they would lead the movement of the remainder of the stack.

I think I might go with this solution unless anyone else has a more efficient approach Smiley Plan to post the source code here when it's done (hopefully over the weekend).

Yay programming!  Grin
4  Game Development / Newbie & Debugging Questions / Theoretical Solitaire Design Questions :) on: 2013-03-01 02:30:21
Hi guys!

In my spare time I have been designing the classes for a Solitaire game I am hoping to program on the weekend. However I'm stuck on a particular problem.

Does anyone have any suggestions as to how to implement the 'drag-ability', of the solitaire cards, more how to distinguish between a card on the top of the stack, versus a card lower down the stack. Basically I'm stuck on how to deal with each card individually according to their position within the solitaire stack.

My initial solution was to have the Card class extend JComponent so I could determine when the mouse was within each component, or 'card', then handle them appropriately according to the mouse movement.

There must be a simpler way? If anyone has any suggestions I would be very very appreciative Smiley
5  Game Development / Newbie & Debugging Questions / Re: Weird swing/JPanel problem! on: 2012-10-19 03:00:14
Sorry, I didn't mean like an actual Swing bug, just a general code bug while using the swing library. 

Using the revalidate() method solved the problem, thanks for the replies guys, much appreciated!  Grin

6  Game Development / Newbie & Debugging Questions / Weird swing/JPanel problem! on: 2012-10-18 08:19:34
I'm have a very strange bug within my program and can't seem to trace it.

When I run my sudoku puzzle game nothing is displayed in the JFrame, but as soon as I resize the JFrame the puzzle and all Swing elements 'pop' or appear into the frame.

Also when I minimize/maximize the frame, the problem is rectified. (Where's the emoticon of the guy hitting himself in the head with a hammer?)

Has anyone ever experienced this sort of swing bug?
7  Game Development / Newbie & Debugging Questions / Re: Quick question regarding the GridBagLayout manager on: 2012-10-16 12:41:26
At a guess, because the JTable inside your JScrollPane has no size?  Try setMinimumSize() or setPreferredSize()?  And why are you calling a table a label?!

If you want to hand-code layouts I'd recommend MigLayout, or quite frankly anything that isn't GridBagLayout!  Wink

You have no idea how many times I have contemplated throwing my laptop out of the window in frustration trying to get Layout managers to behave. The last two days have been a nightmare!  Angry

Thank you for that link, that looks like it is going to solve all of my problems!
8  Game Development / Newbie & Debugging Questions / Quick question regarding the GridBagLayout manager on: 2012-10-16 10:46:18
I'm pulling my hair out trying to learn these layout managers.

Does anyone know what may be the problem here?

This is what I'm getting:


This is what I'm trying to create:


Here's the 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  
46  
47  
48  
49  
50  
51  
52  
53  
   public void createPanel() {
      this.setVisible(true);
      GridBagConstraints gbc = new GridBagConstraints();
      gbc.insets = new Insets(4, 4, 4, 4);
     
      JTable puzzleLabel = new JTable(null);
     
      JLabel usersLabel = new JLabel("Sudoku");
     
      JPanel southPanel = new JPanel();
      JPanel westPanel = new JPanel();

      JPanel detailsPanel = new JPanel();
      detailsPanel.setLayout(new GridBagLayout());
     
      //Button panel button set
     
      gbc.gridx = 0;
      gbc.gridy = 0;
      detailsPanel.add(new JButton("Button"), gbc);
     
      gbc.gridx = 0;
      gbc.gridy = 1;
      detailsPanel.add(new JButton("Button"), gbc);
     
      gbc.gridx = 0;
      gbc.gridy = 2;
      detailsPanel.add(new JButton("Button"), gbc);
     
      /////////////////////////
     
      gbc.gridx = 0;
      gbc.gridy = 0;
      this.add(westPanel, gbc);
     
      gbc.gridx = 1;
      gbc.gridy = 0;
      gbc.anchor = GridBagConstraints.WEST;
      this.add(usersLabel, gbc);
     
      gbc.gridx = 1;
      gbc.gridy = 1;
      this.add(new JScrollPane(puzzleLabel), gbc);
     
      gbc.gridx = 1;
      gbc.gridy = 2;
      this.add(southPanel, gbc);
     
      gbc.gridx = 2;
      gbc.gridy = 1;
      this.add(detailsPanel, gbc);

   }
9  Game Development / Newbie & Debugging Questions / Re: Is there a better way to do this? on: 2012-10-15 13:16:20
Have you looked at CardPanel?

As for instantiating game state objects I actually have a class called GameState that holds everything I need regarding the game.  Then I instantiate it and hold a reference within my main frame instance.  Thus it's accessible wherever I need it.

Naturally the GameState class doesn't include GUI code, loading/saving, etc... just the raw data that represents the guts of the game itself.

My golden rule is "get it working first".  Then refactor if it smells really bad or if you think of a better way to do it later on.

Cheers for the response Loom! Smiley I have had a look at the CardPanel layout manager earlier tonight, but I think after working on this for like 10 hours straight my ability to retain any sort of information is very limited! haha

I manage to get everything working, then look at the code, and re-do the code to make it more readable and cleaner, which is a endless cycle.

I think I have to study more good examples of class structure? (Am I even making sense?) haha, I think it's bed time.
10  Game Development / Newbie & Debugging Questions / Is there a better way to do this? on: 2012-10-15 06:50:16
I'm trying to come up with a type of 'menu screen' system, but really have no idea how to go about it. What I have so far is a JPanel that receives user information, then hides itself when it has done so.

The idea is to hide and reveal JPanels as they are needed.

Also in the game I'm having trouble figuring where is the best place to create objects, especially the user and puzzle objects. Should I design a specific class that does all object creation? Or should I just create them on the fly?

Class design and structure has definitely been my Achilles heel in learning OO programming! Cry

Game Frame
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public class GameFrame extends JFrame {
   
   public static final int GAMEWIDTH = 640;
   public static final int GAMEHEIGHT = 480;
   
   public GameFrame() {
      super("Sudoku || Calkuro");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setSize(GAMEWIDTH, GAMEHEIGHT);
      setResizable(false);
     
      addPanel(new TitlePanel(), BorderLayout.CENTER);
   }
   
   public void addPanel(GamePanel panel, String layout) {
      add(panel, layout);
      panel.createPanel();
      setVisible(true);
     
   }
}


Game Panel
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  
public class TitlePanel extends GamePanel implements ActionListener {
   
   private static final long serialVersionUID = 1L;
   public static final int PANEL_WIDTH;
   public static final int PANEL_HEIGHT;
   
   public InputManager input;
   
   private JPanel dataInput;
   private JLabel titleLabel, userLabel, puzzleLabel, difficultyLabel;
   private JTextField userTextField, puzzleTextField;
   private JButton userLoginButton;
   private JComboBox puzzlesBox, difficultiesBox;

   
   static {
      PANEL_WIDTH = GameFrame.GAMEWIDTH;
      PANEL_HEIGHT = GameFrame.GAMEHEIGHT;
   }

   public TitlePanel(){
     
      String[] puzzles = {"Sudoku", "Calkuro"};
      String[] difficulties = {"Easy", "Medium", "Hard"};
      puzzlesBox = new JComboBox(puzzles);
      difficultiesBox = new JComboBox(difficulties);
      dataInput = new JPanel();
      input = new InputManager();
      titleLabel = new JLabel();
      userLabel = new JLabel();
      puzzleLabel = new JLabel();
      difficultyLabel = new JLabel();
      puzzleTextField = new JTextField();
      userTextField = new JTextField(" ");
      userLoginButton = new JButton("Login");
   }
   
   public void createPanel() {
     
      titleLabel.setFont(new Font("arial", Font.BOLD, 50));
      titleLabel.setForeground(Color.white);
      titleLabel.setText("SUDOKU || CALKURO");
     
      userLabel.setText("Username:                     ");
      userLabel.setForeground(Color.white);
      puzzleLabel.setText("Puzzle:");
      puzzleLabel.setForeground(Color.white);
      difficultyLabel.setText("Difficulty:");
      difficultyLabel.setForeground(Color.white);
     
      userLoginButton.addActionListener(this);
     
      this.setSize(PANEL_WIDTH, PANEL_HEIGHT);
      this.setBackground(Color.DARK_GRAY);
      this.add(titleLabel);
     
      dataInput.setBackground(Color.DARK_GRAY);
      dataInput.setLayout(new GridLayout(5, 5));
      dataInput.add(userLabel);
      dataInput.add(userTextField);
      dataInput.add(puzzleLabel);
      dataInput.add(puzzlesBox);
      dataInput.add(difficultyLabel);
      dataInput.add(difficultiesBox);
      dataInput.add(userLoginButton);

      this.add(dataInput);  
   }

   @Override
   public void actionPerformed(ActionEvent e) {
      Loader.createUser(userTextField.getText());
      Loader.createPuzzle(puzzlesBox.getSelectedItem().toString(), difficultiesBox.getSelectedItem().toString());
      this.setVisible(false);
     
   }

   @Override
   public void update() {}

   @Override
   public void handleInput() {}
}


The "Loader" Class - (Is this even logical?)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public class Loader {

   private static Puzzle sudokuPuzzle;
   private static Puzzle calkuroPuzzle;
   private User user;

   public static void createPuzzle(String puzzleName, String difficulty) {
      if (puzzleName.equals("Sudoku"))
         sudokuPuzzle = new SudokuPuzzle(difficulty);
      if (puzzleName.equals("Calkuro"))
         calkuroPuzzle = new CalkuroPuzzle(difficulty);
   }

   public static void createUser(String userName) {
      User user = new User(userName);
     
   }
}
11  Game Development / Newbie & Debugging Questions / Re: Help with Java Calkuro! on: 2012-10-11 13:52:17
Yay I worked it out Smiley Thanks guys!

12  Game Development / Newbie & Debugging Questions / Re: Help with Java Calkuro! on: 2012-10-11 13:04:32
No rules, the puzzle can be any variation of cages we can come up with.

The main problem I'm having is working out how to group the numbers within the cages.

I'm really stuck. Please help me!  Tongue
13  Game Development / Newbie & Debugging Questions / Help with Java Calkuro! on: 2012-10-11 00:50:18
Hey guys was wondering if anyone could help me out with a problem I am having.

I am trying to build a Calkuro game similar to the one found here:

http://www.youplay.com/games/play/83/170482/

At the moment I'm trying to come up with ideas as to how to 'Group' the cages of numbers on the game grid, (if you follow that earlier link this will make sense).

So far the only solution I can come up with is to hard code in all the possible cage combinations, but there must be an easier way!  Tongue

Any suggestions as to how I could go about creating this would be very appreciated.

Thanks heaps!

14  Discussions / General Discussions / Re: 2D Game Engine Development [Youtube Tutorials] on: 2012-10-03 11:43:59
Hey mate, have been following these tutorials so far they have been great! Awesome work.

Just some feedback from a relatively new Java coder, (I assume this is the target audience you're aiming for).

Some of your explanations are very quick, making it hard to grasp the concept before the video moves onto another topic, although being a video it's easy to go back and replay.
An example being where you explain how the colour class works by reading in the RGB values from the sprite map, had to watch that a few times for it to sink it.

I'm really just nick picking, but I thought you'd appreciate some feedback from someone who has watched your videos.

OK, gotta go watch video 6!  Smiley
15  Game Development / Newbie & Debugging Questions / Re: Help with class design / general software design on: 2012-09-10 07:55:05
What the previous poster said: experience is the best teacher.  Beyond very expensive textbooks, there's not a lot out there that covers design aspects, but one I can recommend is Head First Design Patterns which is a somewhat more modernized and streamlined take on the original.  One thing I really need to stress about design patterns is that they are descriptive, not prescriptive.  As in, they're about naming and cataloging existing best practices, but you don't want to force your program to use them if they're not an obvious natural fit.  Nothing's worse than seeing a program unnecessarily blown up to use Facades of Factories of Strategies of Visitors of blahdeblah etc ad nauseum.  But a program that uses patterns properly can be a thing of beauty.

Another really biblical text in the design area is Bertrand Meyer's Object-Oriented Software Construction.  Meyer loves to explain everything in terms of Eiffel, a language that frankly only continues to exist for Meyer's books and papers, but most of the ideas in there should apply to any language.

What little theory OO has to offer is worth reviewing, and two in particular are:

  • Law of Demeter - Only talk to your "neighbor" interfaces
  • Liskov Substitution Principle - The difference between subtypes and subclasses
     (but remember that a subclass may add interfaces, so don't take it too strictly)




What a great response!! Thank you so much, will definitely check out that material.

Thanks for the advice ra4king and ags1!
16  Game Development / Newbie & Debugging Questions / Help with class design / general software design on: 2012-09-08 04:57:47
Hi again guys, quick question for anyone interested Smiley

Was wondering if anyone knew of some good tutorials or material that teaches good program design, good OOP design techniques, or code architectural organization.

That being the planning and design of classes and class structure.

I am becoming very comfortable with the language now, but still struggling with the correct structure of java classes/programs.

I have been searching and all I can really find are tutorials on the actual building of classes and the such, none on the design aspect.

I hope I'm making sense, only had 2 hours sleep last night!  Cranky Smiley
17  Game Development / Newbie & Debugging Questions / Re: Mouse wheel scrolling problem. on: 2012-09-07 04:01:28
I'm on work now so I can't look deeper. But for first aid, try to little debugging by implement zoom in/out using keyPress, one step per press. This is more accurate and able to prove that your code inside that if block works.

Thanks will give it a try! Smiley
18  Game Development / Newbie & Debugging Questions / Re: Mouse wheel scrolling problem. on: 2012-09-07 03:53:48
I think the problem is I don't know how to structure classes the correct way. The design behind the class structure and overall program structure.

Here's my modified method, which is in a class called "Entity", which basically handles everything that is displayed on the screen. So I thought by "zooming", the entity class
all the subclasses and children of that class would be "zoomed" as well.

The zoom method just checks to see which way the mouse scroll wheel has been rotated and applies the appropriate scaling.

At the moment it only scales 1x.

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  
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;

public class Entity{

   protected double x;
   protected double y;
   protected Sprite sprite;
   protected double dx;
   protected double dy;
   AffineTransform tx;

   public Entity(String ref, int x, int y){
      this.sprite = SpriteStore.get().getSprite(ref);
      this.x = x;
      this.y = y;
      tx = new AffineTransform();
   }

   public void move(int delta) {
      x += (delta * dx) / 1000;
      y += (delta * dy) / 1000;
   }

   public void zoom(Graphics2D g, int scrollAmount){
      if (scrollAmount > 0){
         g.setTransform(tx);
         g.scale(0.9, 0.9);
      } else if (scrollAmount < 0){
         g.setTransform(tx);
         g.scale(1.1, 1.1);
      }
   }

   public void setHorizontalMovement(double dx) {
      this.dx = dx;
   }

   public void setVerticalMovement(double dy) {
      this.dy = dy;
   }

   public double getHorizontalMovement() {
      return dx;
   }

   public double getVerticalMovement() {
      return dy;
   }

   public void draw(Graphics2D g) {
      zoom(g, MouseWheelInputHandler.scrollAmount);
      sprite.draw(g,(int) x,(int) y);
   }

   public int getX() {
      return (int) x;
   }

   public int getY() {
      return (int) y;
   }

   public int getHeight(){
      return sprite.getHeight();
   }

   public int getWidth(){
      return sprite.getWidth();  
   }
}
19  Game Development / Newbie & Debugging Questions / Mouse wheel scrolling problem. on: 2012-09-07 03:15:45
Hey guys, having trouble with a zoom method, can't seem to wrap my head around how to get this working. If anyone could help me I would be very appreciative!  Smiley

Here is the method I am using, (I am using AffineTrasnform to achieve the "zoom" effect).

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
   public void zoom(Graphics2D g){
   
      int scale = 1;
     
      if (MouseWheelInputHandler.scrollAmount > 0){
         g.setTransform(tx);
         scale *= 0.1;
         tx.scale(scale, scale);
         System.out.println("Scroll up");
         MouseWheelInputHandler.scrollAmount = 0;
      } else if (MouseWheelInputHandler.scrollAmount < 0){
         g.setTransform(tx);
         scale *= -0.1;
         tx.scale(scale, scale);
         System.out.println("Scroll down");
         MouseWheelInputHandler.scrollAmount = 0;
      }
   }
20  Game Development / Newbie & Debugging Questions / Re: Basic Java2D rendering problem on: 2012-09-05 08:40:04
Switch
1  
2  
      frame.pack();
      frame.setResizable(false);

so it says
1  
2  
      frame.setResizable(false);
      frame.pack();


That did the trick! Thank you  Smiley
21  Game Development / Newbie & Debugging Questions / Basic Java2D rendering problem on: 2012-09-05 08:08:27
Hey guys, I have been working on a basic isometric tile engine based off this tutorial - http://www.java-gaming.org/topics/basic-game/21919/view.html

Anyone know why I might be getting this white padding around the right hand, and bottom of the screen?

22  Game Development / Newbie & Debugging Questions / Re: Isometric Tiling and General Object Oriented Woes on: 2012-07-19 05:40:34
Nice to see some healthy discussion happening on this thread!  Smiley Thanks for all your helpful and knowledgeable advice!

However, from what I've read so far you're confusing the issue slightly. What jdgamedev said is correct: You should be attempting to separate your objects/classes into logical components that do their job and only their job. But, take this one step further, you need separate your concepts between "Logic/Backend" and "Graphics/Frontend". The class that you're using to store the data about the tiles should probably not know anything about how it's going to be drawn. It shouldn't even know that it is going to be drawn. Instead, it should probably know enough information that you could write several different renders (ASCII, sprite-based isometric, sprite-based isometric 30-degree, 3d, etc.) to draw it.

I think I'm at the stage in my programming where I can understand how object oriented programming works, but am confused with when I should use it.

However, what UprightPath said really hit home to me and helped me to understand the logical aspects of a object oriented structure. (Thank you!)

The more I study source code, the more it is making sense to me also.

I'm glad someone else is feeling the same way as I am! Smiley I am the point now where I understand simple OOP structure, but when it starts to get larger and more complex I'm totally lost.

We can do it!  Smiley

Hey, I'd love to hear your input on the stuff I've put on my blog. It'll be good to hear from someone around my skill level. If you get a chance check it out. Link is in the signature. I'm actually working on tile maps for my game right now. We can probably learn some stuff from each other.

Also, if you have any requests for helpful tips or tutorials let me know. Thanks!

Nice blog jdgamedev, very cool idea! It's inspiring to see someone just as enthusiastic as I am to get into game development! I will be sure to follow your blog! Smiley
23  Game Development / Newbie & Debugging Questions / Re: Isometric Tiling and General Object Oriented Woes on: 2012-07-18 02:31:40
I'm in a similar boat for learning to program but I hope I can give you a few tips.

As far as creating a separate class, I would definitely recommend it. Usually the answer for me is yes anytime I ask myself if I should create another class. It is good OOP and helps a ton with keeping things organized. The fewer classes I have, the harder I find it to remember what each one does haha. When you separate them logically, it's easy to remember each class's function and to remember what you plan with each part.

Also, if you want to get a good idea of how to organize your game, I HIGHLY recommend looking at other game developers' source. I've got a couple projects set up in my Eclipse that Notch wrote for Ludum Dare. They might not be a perfect example because they were done in 48 hours, but they still help guide me through the process.

Best of luck man, good to see someone doing the same thing as me. MORE GAMES!!!

I'm glad someone else is feeling the same way as I am! Smiley I am the point now where I understand simple OOP structure, but when it starts to get larger and more complex I'm totally lost.

We can do it!  Smiley

There's a link to the source of that thing beside the applet ( http://jonjavaweb.orgfree.com/IsoWorldSource.zip ).

Iirc it just stores the objects/blocks in a big 2d array of ArrayLists. The database of how to handle the objects is really nothing special, it's just that the view is "warped" to look isometric when the game is drawn.

Thank you so much for the source code, so awesome! I may or may not have a few questions for you in the future if you'd be willing to help me out Smiley
24  Game Development / Newbie & Debugging Questions / Isometric Tiling and General Object Oriented Woes on: 2012-07-17 14:22:50
Hey guys, recently I have been getting into a lot of Java game development after a semester course on Java at university. I'm doing everything in my own spare time and sometimes it's hard to wrap my head around the more technical aspects of the language.

I have been experimenting with the Slick2D library and have been having a lot of fun making small games based off this Entity Engine Tutorial --> http://slick.cokeandcode.com/wiki/doku.php?id=entity_tutorial

Now the problem I have at the moment is creating a isometric "board" built by separate diamonds. What would be the best way for me to do this? Rather, what would be the most efficient way to do this?

I know how I can store the tiles in a 2 dimensional array based on this --> http://www.java-gaming.org/topics/drawing-isometric-tiles-inside-a-screen/24922/view.html

However what I don't understand is how I should go about implementing this code.

Should I create a new TileMap class that builds the map in another class?

If so how do I go about re-using the one image over and over without creating a new entity every time?

I think I've hit a bit of a wall, and am getting confused with the complexity of some object oriented aspects of coding in general, I am very new!

Any help would be very appreciated! ( Sorry if I'm rambling, I REALLY want to get this stuff!!! Sad )
25  Game Development / Newbie & Debugging Questions / Re: Suggest a project to the new guy! on: 2012-07-12 01:00:43
Just a heads up -- Slick's website is currently out of date. For the latest version of Slick, you should pull it from bitbucket. More info:
http://slick.javaunlimited.net/viewtopic.php?f=3&t=5171

I'd also suggest upgrading to the latest LWJGL since Slick ships with an older version.

Sweet, thanks for the heads up! I'm really liking Slick so far, it makes everything so easy! Smiley Let's you fully concentrate on the awesome game you want to make, without having to worry about to many technical limitations.
26  Game Development / Newbie & Debugging Questions / Re: Suggest a project to the new guy! on: 2012-07-11 13:44:02
Sweet screenshot! How did you do that deterioration of the shields effect?

Concerning Slick2D, it's a wrapper over LWJGL. It has an API very similar to Java2D but it uses LWJGL underneath. It's mainly for people who want to make games with full hardware acceleration but don't want to get into the specifics of OpenGL.

Thanks man!  Smiley For the deterioration effect I just had 4 different sprites loaded into an array, (no damage, little damage, little more damage, and really damaged). Then depending on the "health" of the shields an appropriate sprite was displayed.

That makes total sense now, thanks for explaining that. Smiley
27  Game Development / Newbie & Debugging Questions / Re: Suggest a project to the new guy! on: 2012-07-11 12:06:54
its LWJGL not JLWGL to start of with Tongue

you don't need Slick2d to use LWJGL, Slick2d you could say allows for newer people to use LWJGL and harness its awesomeness, but still be easier then LWJGL.

cokeandcode.com is where you get it, and also has tutorials

slick.cokeandcode.com/

for tuts
http://slick.cokeandcode.com/wiki/doku.php?id=tutorials

God I'm an idiot sometimes!  Cheesy I hate being a total noob, it's embarrassing!

Cheers for the links man! Will get cracking on those tutorials first thing  Smiley
28  Game Development / Newbie & Debugging Questions / Re: Suggest a project to the new guy! on: 2012-07-11 11:51:47
Hi guys, still been working away at my little Java 2D project and have had a million ideas for a more in depth game. I can finally see how it's possible to build games from my own imagination now, which is exciting!  Grin

Like you guys suggested I'm going to start becoming familiar with OpenGL and the JLWGL.

I'm under the impression that the only way to use the JLWGL is through Slick2D?

I'm a little confused, are JLWGL and Slick2D just 2 different libraries? How do they work together?

If I wanted to user the JLWGL and Slick2D for my next project, where should I start? ( where/how to learn ).

Here's a little screen of what I've been working on.

29  Game Development / Newbie & Debugging Questions / Re: Suggest a project to the new guy! on: 2012-07-07 05:09:39
Ra4king! I think I love you!! Haha. Smiley that solved my problem, thank you! I have been pulling my
Hair out for hours over that one! Cheers!
30  Game Development / Newbie & Debugging Questions / Re: Suggest a project to the new guy! on: 2012-07-07 04:39:15
I'm trying to check for every 'alien' in the array list. I'm not very confident with array lists Smiley
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

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

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

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

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

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
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!