10 Replies - 1337 Views - Last Post: 21 December 2011 - 10:22 PM Rate Topic: -----

#1 Ryzix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 21-December 11

Pokemon Type Scrolling Window?

Posted 21 December 2011 - 08:54 PM

Hello guys (:

I am new here and fairly new to Java as well. Now, heres the problem. I understand how to make a side scrolling background for my game I just dont know how to make it as in, well, the pokemon kind? Where you can scroll left, top, down or right and you even have all the collision detections set for the area's off screen.

Can anyone point me in the right direction?
Is This A Good Question/Topic? 0
  • +

Replies To: Pokemon Type Scrolling Window?

#2 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 08:57 PM

I'm not quite sure what you mean by "the pokemon kind"? Are you meaning like movement like in the gameboy game Pokemon? Can move in 4 directions and there are walls cant pass and what not?
Was This Post Helpful? 0
  • +
  • -

#3 Ryzix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 21-December 11

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 08:59 PM

Yes exactly. The only type of game I can make so far is where you set collision detection to the edges of the window. The "Pokemon kind" was the closest thing to a refrence I could think of. My bad.
Was This Post Helpful? 0
  • +
  • -

#4 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 09:03 PM

Ok, well, logic planning time now. How are you wanting to build the foundation for the game? Like how are you wanting the game to be laid out? Is it going to be on a Grid? Will it be painted and use coordinates?

What say you good sir?
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 09:07 PM

Sorry I am too old to know what a Pokemon game is but sounds to me that your need a JSCrollPane

http://docs.oracle.c...ScrollPane.html
Was This Post Helpful? 0
  • +
  • -

#6 Ryzix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 21-December 11

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 09:09 PM

I was planning on using the coordinate set idea. If by coordinate set you mean setting my characters x and y every time any of the keys are touched? I think mainly I also set tbe refrence to pokemon is basically thats how I want my game. xD Not pokemon themed, just in terms of the window and movement. (:
Was This Post Helpful? 0
  • +
  • -

#7 Ryzix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 21-December 11

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 09:17 PM

Thank you, pbl! Thats exactly what I needed. Now, with the JScrollPane I could set global collisions and they're going to still be in affect to my areas of the map when I finally scroll into them, correct?
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 09:23 PM

Yes you can have a world of 5 millions pixels width and 5 millions pixels height behind the Viewport of your scroll area if you want

A quick one that should work
import javax.swing.*;
import java.awt.*;

public class Pokemon extends JPanel {

	public Pokemon() {
		super(null);
		setBackground(Color.YELLOW);
		setPreferredSize(new Dimension(5000, 5000));
	}
	
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		for(int x = 10; x < 4900; x += 200) {
			for(int y = 10; y < 4900; y += 80) {
				g.drawString("Pokemon at " + x + "," + y, x, y);
			}
		}
	}
	
	public static void main(String[] args) {
		JFrame frame = new JFrame("Pokemon game");
		frame.add(new JScrollPane(new Pokemon()));
		frame.setSize(600, 500);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setVisible(true);
	}
}


This post has been edited by pbl: 21 December 2011 - 09:44 PM

Was This Post Helpful? 0
  • +
  • -

#9 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 09:56 PM

I see this being made on a Grid personally, I think it would be a lot easier. You can make JLabel to go in each of the Grid slots in where each label can actually be a picture, giving a layout as well as a true or false value. If can pass through will be true value and will move to the spot facing opposite direction he came from. Aka if he is stand on a square facing forward, hit the right button, he will then move one block over and be facing East, since he came from the square to the west. If the block has false then it will simple make him face that block, aka if he is trying to turn right into a wall, he will simply face east since he is standing on the block to the west of the "Walls" Location. If you use JLabel you can make it a picture as I said, giving it terrain and actually seeing a wall like in the Pokemon game.

The more I think of it you should probably just create an Class called Terrain and it will take an Image and 2 booleans as a parameter in the constructor, image obviously will fill the slot of the grid, the 2 booleans 1 for if passable, and 2nd for isFightable, meaning grass monsters in them.

But yes, I see this being more of a grid thing rather then a Coordinates thing.

Get my drift?

Also, check out this Snake Snippet by pbl. Will probably learn a lot from that.

Edit - If you do not feel like creating own grid and what not, Look into GridWorld. It could be very easy to create a game such as Pokemon in it. However, I think you would like it a lot better creating on own since it is a better experience.

This post has been edited by Fuzzyness: 21 December 2011 - 09:59 PM

Was This Post Helpful? 1
  • +
  • -

#10 Sheph  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 432
  • View blog
  • Posts: 1,020
  • Joined: 12-October 11

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 10:12 PM

I don't understand what you mean by global collisions or offscreen collisions. I would imagine each tile would keep track of it's own collision detection, like Fuzzyness said. I might even consider a byte instead of a boolean, to hold multiple modes of transportation. The viewport doesn't delete the tile when it's not in view, it just doesn't draw it. It is still there, in memory and collision detection intact, unless you decide to not load that area. Besides how could the player walk offscreen if he is always in the center as you ask? :)
Was This Post Helpful? 0
  • +
  • -

#11 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Pokemon Type Scrolling Window?

Posted 21 December 2011 - 10:22 PM

Ya... Fuzzy is right, a grid is better

import javax.swing.*;
import java.awt.*;

public class Pokemon extends JPanel {

	public Pokemon() {
		super(new GridLayout(90,90));
		setBackground(Color.YELLOW);
		setPreferredSize(new Dimension(5000, 5000));
		for(int i = 1; i <= 90; ++i) {
			for(int j = 1; j <= 90; ++j) {
				JLabel label = new JLabel("" + i + " X " + j, SwingConstants.CENTER);
				label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
				add(label);
			}
		}
	}
		
	public static void main(String[] args) {
		JFrame frame = new JFrame("Pokemon game");
		frame.add(new JScrollPane(new Pokemon()));
		frame.setSize(600, 500);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setVisible(true);
	}
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1