Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Plutonium

Member Since 30 Aug 2011
Offline Last Active Jul 27 2014 11:03 AM

#5098458 Component-Entity-System implementation

Posted by Plutonium on 03 October 2013 - 07:47 AM

Hello!

 

I'm trying to implement this systems, because inheritance has bored... I have done this in C# by finding code and changing for my needs. But on C++ I can't find any good example what I want.

 

I created basic Component class. Made some new class from it (SpriteComponent and MovementComponent). Now in Entity I want create list of components. But just don't know how to find it.

 

What I looking for is 3 methods and data structure for holding components .

  1. AddComponent(Component * component); would use it like player.AddComponent(new SpriteComponent(20,30));
  2. GetComponent(...); would use it like player.GetComponent<SpriteComponent>();
  3. RemoveComponent(...); would use it like  player.RemoveComponent<SpriteComponent>();

 

Could anybody say how to implement this thing?

 



#5095595 Open world 3D game without a specific game engine

Posted by Plutonium on 20 September 2013 - 04:36 PM

 

Now, I know it's hard and takes time and the advice is not do it and I understand why. But, is that written in stone? I mean, there is really no reason not to do a 3D game without an existing game engine? Is the knowledge present for everyone willing to learn or you need to be really smart?

 

 

Why You want invent wheel again? If it's done - use it. Big companies spend a lot money to develop (hardware, ppl's too) for them self. But some of these engines are free or open source. So why bother to make your own engine? Yup, You will do it. Why? Game can't be without engine. You won't write whole render basics to every object different. You will make objects same (in parameters) that they could be used with same methods/functions, so if you this one method, you fix everything. That is engine! So please tell me, why you want create your own engine? Don't do mistake. Good game even with engine could take years, and without existing engine... even longer... ;) I would agree if you would be good game developer, which used alot engines and don't liked any of thems. So - create your own. Or find team and create. But now... For newbie... Just don't think that you could make job, which could be done only by big team ;)




#5095498 Open world 3D game without a specific game engine

Posted by Plutonium on 20 September 2013 - 09:56 AM

I'm not the best game developer, but even I know that make game without game engine will be to hard. Why? Game engine have made every hard lifting (graphics, camera, input and so on). You just need write your game. If you would want do game without game engine, you would need make graphics controller (how to render objects, put textures, shaders, alot of matrix calculations (yup, you would need really good math knowledges)), which is really hard to make (I developing small games for 2 years and just using 2D, because 3D is to hard for me now...). And all game engines made alot bugs, and fixed thems. You would do same bugs as them. So why to do that? Just take engine and make game. Sit and write what you really want to do: what game would be about, what features would have and so on. Then look what engine will be good for you ;) but I think most of engine will be ok. I would go for unity, because it's partly free (most of features are free). So if you would fail in making game, you won't loose any money (if you won't buy) ;)




#5090849 Simple network game

Posted by Plutonium on 01 September 2013 - 01:56 PM

First, I highly advise against using the event driven sockets on Windows. They are known to be finicky; they perform poorly; they have a bunch of caveats; and they are not portable.

 

Second, we need to know more to understand what the situation is. Are you and your room-mate both on the same physical network? Do you, or your room-mate, have some kind of firewall running? Is there a router of some sort involved?

The problem you describe sounds like either a problem with Windows Firewall, or with NAT.

 

For now will try event driven, and if that won't satisfy me, then will try something else ;)

 

And thanks for second, because turned off firewall, and connected easily :)




#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