Java 2D game developing

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

30 Replies - 2140 Views - Last Post: 25 August 2013 - 01:19 PM Rate Topic: -----

#1 Hououin_Kyouma  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 21
  • Joined: 29-July 13

Java 2D game developing

Posted 30 July 2013 - 10:29 AM

I am in need of "GENEROUS" JAVA programmers who are willing to share their knowledge about 2D game developing to me. I need a lot help on this one.

I DONT NEED THE CODE FOR THE WHOLE GAME OR SOMEONE WHO WILL DO THE WORK FOR ME OR SOMEONE THAT WILL BECOME MY PERSONAL TUTOR. I JUST NEED GENEROUS JAVA PROGRAMMERS WHO ARE WILLING TO GIVE ME A SAMPLE THAT I CAN ENHANCE AND CODES THAT CAN HELP ME WITH THIS ONE.

So basically, I need to develop a game similar to the one featured on this video (http://www.youtube.com/watch?feature=player_detailpage&v=YuHLE6ES2t4). I'm planning to develop 2D fighting game similar to Street Fighter and other fighting games. It doesn't need to be that complex. Currently, a 2D fighting game that enables two people to fight using the same keyboard will be enough. I have no plans of including an AI yet but it will be helpful if anyone can help me with that. Things that I would want to include in this game are the following: Two player system, Basic movements like jump, punch, kick, and projectiles, Health bar, Power meter (will allow player to shoot projectiles if full),Timer, Character Selection, Pointing System: Best of 3.

I have some experience on JAVA but it is not enough because we haven't gone this far in our class. We haven't tackled about game developing yet that's why I don't have any ideas, but I indeed try some codes I got from other tutorials but it is not the exact thing that I am looking for.

So far I got this Mario like game, I need add the health bar or whatever meter similar to it (I can use it for the power meter too), the attacks like kick punch and stuff and another player character.
package OurGame;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

import javax.swing.ImageIcon;

public class Dude {
	int x, dx, y,nx,nx2,left, dy;
	Image still,jump,reverse;
	
	int ammo = 10;

	 static ArrayList bullets;//Holds number of bullets on screen
	
	ImageIcon s = new ImageIcon("C:/still.png");
	ImageIcon j= new ImageIcon("C:/jump.png");
	ImageIcon l = new ImageIcon("C:/left.png");
	
	public static ArrayList getBullets()
	{
		return bullets;
	}
	public Dude() {
		x = 75;
		left = 150;
		nx = 0;
		nx2= 685;
		y = 172;
		still = s.getImage();
		bullets = new ArrayList();//j
	
	}
	
	public void fire()//Method to run when when fired
	{
		
		System.out.println(bullets.size() + " " + ammo);
		if (ammo > 0){
			ammo--;
		//Create a new bullet object and add it to 
		//array "list" of all bullets on screen.
		Bullet z = new Bullet((left + 60), (y + 154/2));
		bullets.add(z);}
	}

	public void move() {
		if (dx != -1){
			if (left + dx <= 150)
				left+=dx;
			else{
		x = x + dx;
		
		nx2= nx2+dx;
			nx = nx + dx;
	}}
		else
	{
		if (left+dx >0)
		left = left + dx;
	}
		}

	public int getX() {
		return x;
	}

	public int getnX() {
		return nx;
	}
	
	public int getnX2() {
		return nx2;
	}

	public int getdx() {
		return dx;
	}
	
	public Image getImage() {
		return still;
	}

	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_LEFT)
		{		dx = -1;
		still = l.getImage();		}
		
		if (key == KeyEvent.VK_RIGHT)
			{dx = 1;
		still = s.getImage();	
			}
		
		if (key == KeyEvent.VK_SPACE)
		{
			fire();
		}
		
		if (key == KeyEvent.VK_UP)
			{dy = 1;
			still = j.getImage();
			}			}

	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();

		if (key == KeyEvent.VK_LEFT)
			dx = 0;

		if (key == KeyEvent.VK_RIGHT)
			dx = 0;
		
		if (key == KeyEvent.VK_UP)
			{dy = 0;
			still = s.getImage();}
			}
	}

package OurGame;

import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;

import javax.swing.*;

public class Board extends JPanel implements ActionListener, Runnable {
	Dude p;
	public Image img;
	Timer time;
	int v = 172;
	Thread animator;

	 static Font font = new Font("SanSerif", Font.BOLD, 24);
	  
	boolean a = false;
	boolean done2 = false;
	
	public Board() {
		p = new Dude();
		addKeyListener(new AL());
		setFocusable(true);
		ImageIcon i = new ImageIcon("C:/testp.jpg");
		img = i.getImage();
		time = new Timer(5, this);
		time.start();
	}

	public void actionPerformed(ActionEvent e) {
	
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			//This is how to get a current element in an arrayList
			//similar to x[2] in a normal array
			 Bullet m = (Bullet) bullets.get(w);//draw:
			 if (m.getVisible() == true)
			 {
				 m.move();
			 }
			 else bullets.remove(w);
		}


		
		p.move();
		repaint();
	}

	public void paint(Graphics g) {
		if (p.dy == 1 && done2 == false) {
			done2 = true;
			animator = new Thread(this);
			animator.start();
		}
p.y = v;
		super.paint(g);
		Graphics2D g2d = (Graphics2D) g;

		//Get bullets from ArrayList
		
		if ((p.getX() - 590) % 2400 == 0)// p.getX() == 590 || p.getX() == 2990)
			p.nx = 0;
		if ((p.getX() - 1790) % 2400 == 0)// p.getX() == 1790 || p.getX() == 4190)
			p.nx2 = 0;

		g2d.drawImage(img, 685 - p.getnX2(), 0, null);
		if (p.getX() > 590) {
			g2d.drawImage(img, 685 - p.getnX(), 0, null);
		}
		
		g2d.drawImage(p.getImage(), p.left, v, null);

		if (p.getdx() == -1) {
			
			g2d.drawImage(img, 685 - p.getnX2(), 0, null);
			g2d.drawImage(p.getImage(), p.left, v, null);
		}
		
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			//This is how to get a current element in an arrayList
			//similar to x[2] in a normal array
			 Bullet m = (Bullet) bullets.get(w);//draw:
	            g2d.drawImage(m.getImage(), m.getX(), m.getY(), null);

		}
		g2d.setFont(font);
		g2d.setColor(Color.BLUE);
		g2d.drawString("Ammo left: " + p.ammo, 500, 50);
	}

	private class AL extends KeyAdapter {
		public void keyReleased(KeyEvent e) {
			p.keyReleased(e);
		}

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

	boolean h = false;
	boolean done = false;

	public void cycle() {

		if (h == false)
			v--;
		if (v == 125)
			h = true;
		if (h == true && v <= 172) {
			v++;
			if (v == 172) {
				done = true;
			}
		}
	}

	public void run() {

		long beforeTime, timeDiff, sleep;

		beforeTime = System.currentTimeMillis();

		while (done == false) {

			cycle();

			timeDiff = System.currentTimeMillis() - beforeTime;
			sleep = 10 - timeDiff;

			if (sleep < 0)
				sleep = 2;
			try {
				Thread.sleep(sleep);
			} catch (InterruptedException e) {
				System.out.println("interrupted");
			}

			beforeTime = System.currentTimeMillis();
		}
		done = false;
		h = false;
		done2 = false;
	}

} 

 
package OurGame;

import javax.swing.*;

public class Frame {

	public Frame(){
		JFrame frame = new JFrame();
		frame.add(new Board());	
		frame.setTitle("Game");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(700,365);
		frame.setVisible(true);
		frame.setLocationRelativeTo(null);
	}
	public static void main(String[] args){
		new Frame();
	}
} 

 
package OurGame;

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

public class Bullet {
	int x, y;//-- Controls the CURRENT location of THIS bullet
	//Each object of this class is a new BULLET
	 Image img;
	boolean visible;
	//sets weather THIS bullet is visible or not

	
	public int getX()
	{
		return x;
	}

	public boolean getVisible()
	{
		return visible;
	}
	
	public int getY()
	{
		return y;
	}
	
	public Image getImage()
	{
		return img;
	}
	
	public Bullet(int startX, int startY)
	{
		ImageIcon newBullet = new ImageIcon("C:/bullet.png");
		img = newBullet.getImage();
		x = startX;
		y = startY;
		visible = true;
	}
	//Just like the move class in Dude class...
	public void move(){
		x = x + 2; //x + bullet speed
		if (x > 700)// if x > board width
			//Make the bullet invisible
			visible = false;
	}
} 

This post has been edited by modi123_1: 30 July 2013 - 10:36 AM
Reason for edit:: fixed botched code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Java 2D game developing

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,774
  • Joined: 12-June 08

Re: Java 2D game developing

Posted 30 July 2013 - 10:35 AM

Quote

So far I got this Mario like game, I need add the health bar or whatever meter similar to it (I can use it for the power meter too), the attacks like kick punch and stuff and another player character.

.... okay and what exactly do you need help on? I mean that code looks to be awfully similar to stuff I've seen floating around since 2010. Are you asking for someone to do a complete conversion for you so you can go off and mod that conversion to what ever you are doing?
Was This Post Helpful? 0
  • +
  • -

#3 Hououin_Kyouma  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 21
  • Joined: 29-July 13

Re: Java 2D game developing

Posted 30 July 2013 - 10:51 AM

I mentioned it already, I need help on he attack, health bar, and adding another character player. Ideas , examples, and hints will be good if you don't want to share the code.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,774
  • Joined: 12-June 08

Re: Java 2D game developing

Posted 30 July 2013 - 10:54 AM

Well think about.

Attack - some method that has a value to subtract f rom the health of the other character when contact/collision is made.
Health - some number value that indicates 'alive' or 'dead'. The bar is just a visual queue.
Another player? That's about as bad as creating a second instance of the user class and making sure the initialize, update, draw, keyboard commands respond to this object as well.

There.. go nuts.

As someone said - this is way outside of your experience level.. just thrashing around in someone else's code is not going to go well for you.
Was This Post Helpful? 0
  • +
  • -

#5 Hououin_Kyouma  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 21
  • Joined: 29-July 13

Re: Java 2D game developing

Posted 30 July 2013 - 11:05 AM

Okay, thanks. I got the health bar now, thanks to that visual queue hint same with the attacks. But I still can't get the another player character crap.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,774
  • Joined: 12-June 08

Re: Java 2D game developing

Posted 30 July 2013 - 11:06 AM

... make another instance of your class 'Dude'. Anywhere (in the game loop) the original instance is being used mimic that behavior with the new instance's variable name.
Was This Post Helpful? 0
  • +
  • -

#7 Hououin_Kyouma  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 21
  • Joined: 29-July 13

Re: Java 2D game developing

Posted 30 July 2013 - 11:42 AM

I tried to do what you said but I can't seem to get the crap work, any other approaches?
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,774
  • Joined: 12-June 08

Re: Java 2D game developing

Posted 30 July 2013 - 11:44 AM

No.. that _is_ the approach. If you want a second instance of a class in the problem you create another variable, instantiate it, and hook it up (where and how) like the first instance. Basic OOP 101.
Was This Post Helpful? 0
  • +
  • -

#9 Hououin_Kyouma  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 21
  • Joined: 29-July 13

Re: Java 2D game developing

Posted 31 July 2013 - 02:13 PM

I'm still working on the another player character feature, I added another dude but instead of getting 2 dudes the first one was lost and only the dude2 is visible and it cant jump too. Mind looking at my code for a moment and pinpointing my mistake?

package OurGame;

import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;

import javax.swing.*;

public class Board extends JPanel implements ActionListener, Runnable {
	Dude p;
	Dude2 p2;
	public Image img;
	Timer time;
	int v = 172,v2=172;
	Thread animator;

	 static Font font = new Font("SanSerif", Font.BOLD, 24);
	  
	boolean a = false;
	boolean done2 = false;
	
	public Board() {
		p = new Dude();
		p2=new Dude2();
		addKeyListener(new AL());
		setFocusable(true);
		ImageIcon i = new ImageIcon("C:/testp.jpg");
		img = i.getImage();
		time = new Timer(5, this);
		time.start();
	}

	public void actionPerformed(ActionEvent e) {
	
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			//This is how to get a current element in an arrayList
			//similar to x[2] in a normal array
			 Bullet m = (Bullet) bullets.get(w);//draw:
			 if (m.getVisible() == true)
			 {
				 m.move();
			 }
			 else bullets.remove(w);
		}


		
		p.move();
		repaint();
	
		ArrayList bullets2 = Dude.getBullets();
		for (int w2 = 0; w2 < bullets2.size(); w2++)
		{
			//This is how to get a current element in an arrayList
			//similar to x[2] in a normal array
			 Bullet m2 = (Bullet) bullets2.get(w2);//draw:
			 if (m2.getVisible() == true)
			 {
				 m2.move();
			 }
			 else bullets2.remove(w2);
		}


		
		p2.move();
		repaint();
	}

	public void paint(Graphics g) {
		if (p.dy == 1 && done2 == false) {
			done2 = true;
			animator = new Thread(this);
			animator.start();
		}
p.y = v;
		super.paint(g);
		Graphics2D g2d = (Graphics2D) g;

		//Get bullets from ArrayList
		
		if ((p.getX() - 590) % 2400 == 0)// p.getX() == 590 || p.getX() == 2990)
			p.nx = 0;
		if ((p.getX() - 1790) % 2400 == 0)// p.getX() == 1790 || p.getX() == 4190)
			p.nx2 = 0;

		g2d.drawImage(img, 685 - p.getnX2(), 0, null);
		if (p.getX() > 590) {
			g2d.drawImage(img, 685 - p.getnX(), 0, null);
		}
		
		g2d.drawImage(p.getImage(), p.left, v, null);

		if (p.getdx() == -1) {
			
			g2d.drawImage(img, 685 - p.getnX2(), 0, null);
			g2d.drawImage(p.getImage(), p.left, v, null);
		}
		
		ArrayList bullets = Dude.getBullets();
		for (int w = 0; w < bullets.size(); w++)
		{
			//This is how to get a current element in an arrayList
			//similar to x[2] in a normal array
			 Bullet m = (Bullet) bullets.get(w);//draw:
	            g2d.drawImage(m.getImage(), m.getX(), m.getY(), null);

		}
		g2d.setFont(font);
		g2d.setColor(Color.BLUE);
		g2d.drawString("Ammo left: " + p.ammo, 500, 50);
	
		
p2.y = v2;
		super.paint(g);
		Graphics2D gd2 = (Graphics2D) g;

		//Get bullets from ArrayList
		
		if ((p2.getX() - 590) % 2400 == 0)// p.getX() == 590 || p.getX() == 2990)
			p2.nx = 0;
		if ((p.getX() - 1790) % 2400 == 0)// p.getX() == 1790 || p.getX() == 4190)
			p2.nx2 = 0;

		g2d.drawImage(img, 685 - p2.getnX2(), 0, null);
		if (p2.getX() > 590) {
			g2d.drawImage(img, 685 - p2.getnX(), 0, null);
		}
		
		g2d.drawImage(p2.getImage(), p2.left, v2, null);

		if (p2.getdx() == -1) {
			
			g2d.drawImage(img, 685 - p2.getnX2(), 0, null);
			g2d.drawImage(p2.getImage(), p2.left, v2, null);
		}
		
		ArrayList bullets2 = Dude.getBullets();
		for (int w2 = 0; w2 < bullets2.size(); w2++)
		{
			//This is how to get a current element in an arrayList
			//similar to x[2] in a normal array
			 Bullet m2 = (Bullet) bullets2.get(w2);//draw:
	            g2d.drawImage(m2.getImage(), m2.getX(), m2.getY(), null);

		}
		g2d.setFont(font);
		g2d.setColor(Color.BLUE);
		g2d.drawString("Ammo left: " + p2.ammo, 50, 500);
	}
	private class AL extends KeyAdapter {
		public void keyReleased(KeyEvent e) {
			p.keyReleased(e);
			p2.keyReleased(e);
		}

		public void keyPressed(KeyEvent e) {
			p.keyPressed(e);
			p2.keyPressed(e);
		}
	}

	boolean h = false;
	boolean done = false;

	public void cycle() {

		if (h == false)
			v--;
		if (v == 125)
			h = true;
		if (h == true && v <= 172) {
			v++;
			if (v == 172) {
				done = true;
			}
		}
	}

	public void run() {

		long beforeTime, timeDiff, sleep;

		beforeTime = System.currentTimeMillis();

		while (done == false) {

			cycle();

			timeDiff = System.currentTimeMillis() - beforeTime;
			sleep = 10 - timeDiff;

			if (sleep < 0)
				sleep = 2;
			try {
				Thread.sleep(sleep);
			} catch (InterruptedException e) {
				System.out.println("interrupted");
			}

			beforeTime = System.currentTimeMillis();
		}
		done = false;
		h = false;
		done2 = false;
	}

}

package OurGame;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

import javax.swing.ImageIcon;

public class Dude2 {
	int x, dx, y,nx,nx2,left, dy;
	Image still,jump,reverse;
	
	int ammo = 10;

	 static ArrayList bullets2;//Holds number of bullets on screen
	
	ImageIcon s = new ImageIcon("C:/left.png");
	ImageIcon j= new ImageIcon("C:/jump.png");
	ImageIcon l = new ImageIcon("C:/still.png");
	
	public static ArrayList getBullets()
	{
		return bullets2;
	}
	public Dude2() {
		x = 70;
		left = 150;
		nx = 0;
		nx2= 685;
		y = 172;
		still = s.getImage();
		bullets2 = new ArrayList();//j
	
	}
	
	public void fire()//Method to run when when fired
	{
		
		System.out.println(bullets2.size() + " " + ammo);
		if (ammo > 0){
			ammo--;
		//Create a new bullet object and add it to 
		//array "list" of all bullets on screen.
		Bullet z = new Bullet((left + 60), (y + 154/2));
		bullets2.add(z);}
	}

	public void move() {
		if (dx != -1){
			if (left + dx <= 150)
				left+=dx;
			else{
		x = x + dx;
		
		nx2= nx2+dx;
			nx = nx + dx;
	}}
		else
	{
		if (left+dx >0)
		left = left + dx;
	}
		}

	public int getX() {
		return x;
	}

	public int getnX() {
		return nx;
	}
	
	public int getnX2() {
		return nx2;
	}

	public int getdx() {
		return dx;
	}
	
	public Image getImage() {
		return still;
	}

	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_A)
		{		dx = -1;
		still = l.getImage();		}
		
		if (key == KeyEvent.VK_D)
			{dx = 1;
		still = s.getImage();	
			}
		
		if (key == KeyEvent.VK_X)
		{
			fire();
		}
		
		if (key == KeyEvent.VK_W)
			{dy = 1;
			still = j.getImage();
			}			}

	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();

		if (key == KeyEvent.VK_A)
			dx = 0;

		if (key == KeyEvent.VK_D)
			dx = 0;
		
		if (key == KeyEvent.VK_W)
			{dy = 0;
			still = s.getImage();}
			}
	}

package OurGame;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

import javax.swing.ImageIcon;

public class Dude {
	int x, dx, y,nx,nx2,left, dy;
	Image still,jump,reverse;
	
	int ammo = 10;

	 static ArrayList bullets;//Holds number of bullets on screen
	
	ImageIcon s = new ImageIcon("C:/still.png");
	ImageIcon j= new ImageIcon("C:/jump.png");
	ImageIcon l = new ImageIcon("C:/left.png");
	
	public static ArrayList getBullets()
	{
		return bullets;
	}
	public Dude() {
		x = 75;
		left = 150;
		nx = 0;
		nx2= 685;
		y = 172;
		still = s.getImage();
		bullets = new ArrayList();//j
	
	}
	
	public void fire()//Method to run when when fired
	{
		
		System.out.println(bullets.size() + " " + ammo);
		if (ammo > 0){
			ammo--;
		//Create a new bullet object and add it to 
		//array "list" of all bullets on screen.
		Bullet z = new Bullet((left + 60), (y + 154/2));
		bullets.add(z);}
	}

	public void move() {
		if (dx != -1){
			if (left + dx <= 150)
				left+=dx;
			else{
		x = x + dx;
		
		nx2= nx2+dx;
			nx = nx + dx;
	}}
		else
	{
		if (left+dx >0)
		left = left + dx;
	}
		}

	public int getX() {
		return x;
	}

	public int getnX() {
		return nx;
	}
	
	public int getnX2() {
		return nx2;
	}

	public int getdx() {
		return dx;
	}
	
	public Image getImage() {
		return still;
	}

	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_LEFT)
		{		dx = -1;
		still = l.getImage();		}
		
		if (key == KeyEvent.VK_RIGHT)
			{dx = 1;
		still = s.getImage();	
			}
		
		if (key == KeyEvent.VK_SPACE)
		{
			fire();
		}
		
		if (key == KeyEvent.VK_UP)
			{dy = 1;
			still = j.getImage();
			}			}

	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();

		if (key == KeyEvent.VK_LEFT)
			dx = 0;

		if (key == KeyEvent.VK_RIGHT)
			dx = 0;
		
		if (key == KeyEvent.VK_UP)
			{dy = 0;
			still = s.getImage();}
			}
	} 

This post has been edited by modi123_1: 31 July 2013 - 02:21 PM
Reason for edit:: code tags use them right

Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,774
  • Joined: 12-June 08

Re: Java 2D game developing

Posted 31 July 2013 - 02:23 PM

For Pete's sake code tags.. highlight your code and click the 'code' button.


Why do you have a second class called 'dude2'? Is there a different between dude2 and dude? That's the whole point of a class. You make your class.. and each time you create an instance of the class the app carves out that new instance's own chunk of memory that is separate from any other instance of that class.

Think about your class as a cookie cutter press.. You make the shape/press/cookie cutter once, right? Each time you press the cutter into the dough that makes a new cookie that is separate and different from any cookie that was pressed before or after.. but they are all of the same shape as the cookie cutter, right? OOP is like that.
Was This Post Helpful? 0
  • +
  • -

#11 Hououin_Kyouma  Icon User is offline

  • New D.I.C Head

Reputation: -7
  • View blog
  • Posts: 21
  • Joined: 29-July 13

Re: Java 2D game developing

Posted 01 August 2013 - 06:36 AM

There's a difference between Dude and Dude2, the controls and I also plan to link diff images for Dude2 that's why i created a separate class. I still can't create a second character here. Closer hints maybe?
Was This Post Helpful? 0
  • +
  • -

#12 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,774
  • Joined: 12-June 08

Re: Java 2D game developing

Posted 01 August 2013 - 06:47 AM

Well, no.. that's not how it should work. If the classes are identical except for an image and controls then you should be able to make function or two that takes in separate sets, or just sets a boolean flag to determine which set you want, for those parts. Again OOP.

As for why its not drawing - who knows in that blown up chunk of code. My guess is you are making too many graphics objects in the 'paint' method.
Was This Post Helpful? 0
  • +
  • -

#13 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Java 2D game developing

Posted 01 August 2013 - 09:07 AM

How can you use 'extends' and not know about OOP?
Was This Post Helpful? 0
  • +
  • -

#14 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9487
  • View blog
  • Posts: 35,774
  • Joined: 12-June 08

Re: Java 2D game developing

Posted 01 August 2013 - 09:16 AM

@butch - a quick check and shows the code from dec 2010.. http://pastebin.com/QVNa1aDb/ Hmm.. hmmmmmm.. probably not the OPs?!
Was This Post Helpful? 0
  • +
  • -

#15 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Java 2D game developing

Posted 01 August 2013 - 09:21 AM

I thought as much, modi. It's a shame.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3