Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Plutonium

Member Since 30 Aug 2011
Offline Last Active Today, 07:40 AM

#4939965 Where do i start :(

Posted by Plutonium on 13 May 2012 - 10:38 PM

Start learning XNA. It uses C# and give a lots tutorials.


#4939731 Question about gamedev

Posted by Plutonium on 13 May 2012 - 02:07 AM

Here, some links. Maybe they will be usefull:
http://zetcode.com/tutorials/javaswingtutorial/ for understand swing
http://zetcode.com/tutorials/javagamestutorial/ later try this. I suggest to read code, understand, and upgrade games. I think it would give some knowledge :)
http://www.youtube.com/user/TheJavaHub and this guy have some good tutorials :)


#4935539 Beginners with a lot of game ideas

Posted by Plutonium on 28 April 2012 - 02:06 AM

First of all - do simple games, to understand how to make games. If you will start from big project, there is possibility that you wont finish it in first attempt. With more games done, you will understand more and more. Now when I remember what game i was doing about years ago, I starting to laugh, because it looks so silly :)
And second - read a lot of tutorials. More tutorials - more ideas how do one or another thing, and with more ideas - more possibilities make something really cool :)


#4934970 Any tutorials on creating start-up menus?

Posted by Plutonium on 25 April 2012 - 11:32 PM

Tried to simplified it. State, MeniuState, GamePlayState, and in Core updating currentState and doing every switching between states. Every time time I change state, I set that state is used first time, so then variables init would be used only once. And with some event, changing from state to state (MeniuState sets gamePlay if you press Play button). And every time i change states, I hide all panels, and add new (not best choice, because after a lot changing there will be a lot panels added to frame, but just not visible)

package towerdefense;
public abstract class State implements ActionListener {
	private boolean firstFrame;
	private boolean pause;
	private int gameSpeed;
	ArrayList<JPanel> panels;
	public State() {
		firstFrame = true;
		pause = false;
		panels = new <JPanel>ArrayList();
	}
	abstract void loadImages();
	abstract void init();
	abstract void update(long frameDuration);
	abstract void draw(Graphics2D g2d);
	abstract void input(InputHandler input);

}

public class Meniu extends State {
	private boolean gamePlay;
	JButton btnPlay;
	@Override
	void loadImages() {
	}
	@Override
	void init() {
		gamePlay = false;
	}
	@Override
	void update(long frameDuration) {
	}
	@Override
	void draw(Graphics2D g2d) {
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == btnPlay) {
			setGamePlay(true);
		}
	}
	@Override
	void input(InputHandler input) {
	}
	public boolean isGamePlay() {
		return gamePlay;
	}
}
public class GamePlay extends State {
	private boolean gameOver;
	private boolean meniu;
	private boolean win;
	@Override
	void loadImages() {

	}
	@Override
	void init() {
	}
	@Override
	void update(long frameDuration) {
	}
	@Override
	void draw(Graphics2D g2d) {

	}
	@Override
	void input(InputHandler input) {
	}
	@Override
	public void actionPerformed(ActionEvent e) {
	  

	}

	public boolean isGameOver() {
		return gameOver;
	}
	public boolean isMeniu() {
		return meniu;
	}
	public boolean isWin() {
		return win;
	}
}

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
public class Core extends Canvas {
	GamePlay gamePlay;
	Meniu meniu;
	GameOver gameOver;
	Win win;
	State cState;
  
  
	public Core() {
		initCore();
		gamePlay = new GamePlay();
		meniu = new Meniu();
		gameOver = new GameOver();
		fps = new FramePerSecond();
		win = new Win();
		cState = meniu;
	}
	private void initCore() {
		//window settings
		frame = new JFrame();
		frame.setLocation(200, 100);
		frame.setResizable(false);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBackground(backColor);
		setForeground(forColor);
	  
		running = true;
		pause = false;
	}
	private void addPanel(JPanel panel) {
		frame.add(panel);
	}
	private void secondInit() {

		panel = (JPanel) frame.getContentPane();
		//player = (JPanel) frame.getContentPane();
		//  panel.add(button);
		panel.setPreferredSize(new Dimension(screenW - 10, screenH - 10));
		panel.setLayout(null);
		setBounds(0, 0, screenW, screenH);
		panel.add(this);
		setIgnoreRepaint(true);
		frame.pack();
		createBufferStrategy(2);
		strategy = getBufferStrategy();
		g2d = (Graphics2D) strategy.getDrawGraphics();
		input = new InputHandler(this);
	}
	//==========================================================================
	//method for whole application starting
	//==========================================================================
	public void run() {
		gameLoop();
	}
	//==========================================================================
	//gameLoop (dont't think that need comment it
	//basic parts of it is: input, update and draw (rendering)
	//==========================================================================
	private void gameLoop() {
		 while (running) {
			//state swapping
			stateSwaping();

			//pausing game
			if (cState.isPause()) {
				setPause(true);
			} else {
				setPause(false);
			}
			//frameDuration calculation. Used for timeBased movement in game
			//or could be used for fps calculating
			frameDuration = System.nanoTime() - startingTime;
			startingTime = System.nanoTime();

			//first input
			cState.input(input);
			//second is update, but only works if state is not paused
			if (!isPause()) {
				cState.update(frameDuration * cState.getGameSpeed());
			}
			//graphics thing
			//something with graphichs method, because needed every frame call,
			//so mnimized gameLoop by putting it in method
			//later use draw, and disposo (just do it, don't know why)
			graphics();
			cState.draw(g2d);
			g2d.dispose();
		}
	}
	//==========================================================================
	//state pause methods
	//mostly using for gamePlay pausing
	//why? because meniu and gameOver states dont need pause function
	//==========================================================================
	public boolean isPause() {
		return pause;
	}
	public void setPause(boolean pause) {
		this.pause = pause;
	}
	//==========================================================================
	//set state as cState, and set that state is new
	//==========================================================================
	private void changeState(State state) {
		this.cState = state;
		cState.setFirstFrame(true);
		  }
	//==========================================================================
	//hide cState panels
	//==========================================================================
	private void hidePanels() {
		for (int i = 0; i < cState.getPanels().size(); i++) {
			cState.panels.get(i).setVisible(false);
		}
	}
	//==========================================================================
	//there is going all state swaping, from one state to another and so on
	//==========================================================================
	private void stateSwaping() {
		//from meniu to gamePlay
		if (cState == meniu) {
			if (meniu.isGamePlay()) {
				hidePanels();
				changeState(gamePlay);
				gamePlay.setChoosenMap(meniu.getMap());
				meniu.setGamePlay(false);
			}
		}
		//from gamePlay to meniu
		if (cState == gamePlay) {
			if (gamePlay.isMeniu()) {
				hidePanels();
				changeState(meniu);
				gamePlay.setMeniu(false);
			}
		}
		//if gamePlay is gameOver (some number of minions reached end of map)
		//then is changed to gameOver state.
		if (cState == gamePlay) {
			if (gamePlay.isGameOver()) {
				hidePanels();
				changeState(gameOver);
				gamePlay.setGameOver(false);
			}
		}
	  
		 //if gamePlay is WIN (killed all minions waves)
		if (cState == gamePlay) {
			if (gamePlay.isWin()) {
				hidePanels();
				changeState(win);
				gamePlay.setWin(false);
			}
		}
	  
		//from gamePlay to meniu (or in other words - program restart, without
		//only changing states)
		if (cState == gameOver) {
			if (gameOver.isMeniu()) {
				hidePanels();
				changeState(meniu);
				gameOver.setMeniu(false);
			}
		}

		//======================================================================
		//if cState is launched first time (cState has it first frame)
		//when i need to do:
		//1. load cState images
		//2. init its variables
		//3. add cState panels to window (possible adding same panels if swaping
		//was done alot)
		//4. second init for core, that new panels would be add nicely to frame
		//5. set that frame has been used for first time
		if (cState.isFirstFrame()) {
			cState.loadImages();
			cState.init();
			for (int i = 0; i < cState.getPanels().size(); i++) {
				addPanel(cState.getPanels().get(i));
			}
			secondInit();
		  
			cState.setFirstFrame(false);
		}
	}

}



#4929262 Creating a simple game, really simple !

Posted by Plutonium on 08 April 2012 - 02:58 AM

Choose any language. I suggest C++ or Java for starting, but of course you can pick any other. Later go to youtube and look programming tutorials (I suggest this guys http://www.youtube.com/user/thenewboston tutorials). And after learn something - create simple game, like guess random number, or tic-tac-toe :)


#4928512 Reading from a File [Java]

Posted by Plutonium on 05 April 2012 - 09:53 AM

It's just suggestion. Make class Item, which have variables: name, stat1, stat2. Later create class extended from Item. For example shield, sword and so on. Now all items will have same size of variables, and you don't need difference reading strategy. Always will read name, stat1,stat2. And then creating object depending on name. So if it's sword, i will create Sword object where stat1 will be for example ATK.

And about reading, I think it's something with StringTokenizer. http://www.java-examples.com/parse-csv-file-using-stringtokenizer-example


PARTNERS