Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Naughtyusername

Member Since 17 Mar 2013
Offline Last Active Jul 24 2014 07:04 PM

Topics I've Started

SFML 2.1 OOP Code Review

09 January 2014 - 01:17 AM

(Source is attached, there's too much to code tag in here.)

 

Hello, ive recently spent alot of time working on improving my OOP knowledge so i can make a game where the code files don't make me sick smile.png.

 

i would like some experienced C++ Programmers(SFML knowledge or Not) to review my code and let me know of any bonehead mistakes ive made, or areas where i could improve something, that kind of thing.

 

i do ask that you please don't comment on the formatting of the text, or something of the like.(i.e.things that don't help me with OOP, things that are mostly/wholly subjective opinions, Unless you 100% whole heatedly think that it is something that i need to know and would be very beneficial to me.)

 

Thanks!

 

(as of the build you guys can download, debug & release run perfectly and there is no errors (at least none ive noticed in the many hours with it.)

(also id like to note, currently this isn't a game of any kind, im just working on mechanics (Gravity, Collision, Ect.) and as my knowledge grows i will slowly piece it into a game.)


Help with multiple shapes/sprites (SFML)

24 November 2013 - 06:07 PM

Hi, ive been able to draw as many shapes as i desire using a vector, the problem is im unsure of how to interact with them individually.

 

say for example, i want the max amount of enemies allowed to spawn to be 5, and when one of the currently spawned enemies exits the screen, it 'dies' then another one is allowed to spawn.

 

or in the case if when im making a snake game, how would i go about only drawing 1 shape at the end of my snake each time the snake 'eats' the 'food'.

 

do i have to use iterators? what would i have to use to do this kind of thing?

 

im not asking for anyone to write the code for me, i just dont know what i need to be using, and i dont have much experience with std::vectors and pretty much none of iterators. so just reading the C++ doc really hasn't helped me figure this out.

 

this is the basic (probably not optimal) code i have for drawing multiple shapes with a vector.(not full source, just the code for the shape vector)

(what i see that i could do, but am not sure if optimal, or even if it will work as i havent tried yet, is have:

 

int MaxSpawn = 5;

 

if(Alive == true)

{

    for(int i = 0; i <= MaxSpawn; i++) Window.draw(Bricks[i]);

}

but thats not how i want to do it, because it doesnt do what i want still.

outside the main game loop:
sf::RectangleShape Square;

	vector<sf::RectangleShape> Bricks(10, sf::RectangleShape(Square));

	for (int i = 0; i < Bricks.size(); i++)
	{
		Bricks[i].setSize(sf::Vector2f(25, 25));
		Bricks[i].setFillColor(sf::Color::Green);
		Bricks[i].setPosition(20 + (i * 15), Height/2);
	}
inside main loop:
//Draw Here
		Window.clear();

		for(int i = 0; i < Bricks.size(); i++)
		{
			Window.draw(Bricks[i]);
		}

		Window.display();


C++ SFML Code Review

13 November 2013 - 12:52 AM

Hello! i have been programming in C++ for about a year now. I was just wondering if some of you veteran programmers could give me your thoughts on my code, let me know what i have done wrong, what ive done well, ect. don't hesitate to say something in here is absolutely horrible, please let me know. there is a few parts in here that i hate the way i did, but wasn't sure about another way of doing it. and it just being a prototype some of the things i just didn't bother messing with.

 

one thing im going to add before moving switching back to using OOP, is timing. if you guys have any advice on that, it would be appreciated as well.

im interested in what you think about how i handled the states, if i should go about it another way, or if the way i did it is good.

Here is a link to paste-bin if you don't want to download the .zip attached below. http://pastebin.com/bmCmwYRA

this is using the SFML 2.1 Lib, in case anyone is looking at this is interested in SFML/Seeking Help with SFML.

 

Thanks!


I Need Help Getting Started

18 June 2013 - 08:07 PM

(first off, sorry if this is the wrong thread, it seems correct, but i really don't know)

 

i have made 1 game in C++ (using the allegro 5 lib) following a tutorial. it made sense with the guy walking me along. i thought i understood everything, then all of a sudden i'm on my own, and can't figure out how to solve most of my problems, i spend more time googling "How to do this in C++, how to do that, etc" than i do doing anything else it seems. 

 

when i do finally get started on my own project, i always get too ambitious and then everything fails do to me adding too many things that have no purpose.

 

i'm sorry to throw all this at you, but i'm just so lost and need for someone to point me to a tutorial that covers more complicated aspects of game programming, i want a tutorial that at the minimum teaches me how to program a 2d/3d RPG game, so there is quite the variety of classes, and complex things that will teach me better ways to handle things, that will give me the help i need with using classes. i feel quite confident with my understanding of the C++ language, its just when getting into the libraries and API's that mess me up, i'm also still kinda rusty with classes.

 

i don't want this to sound like i haven't looked and all i want is other people to do it for me, i'm not that guy, and i'm sorry if it seems that way, but i'm lost with this right now and really need some help on this, anything you can offer to help out would be awesome, and i would forever be thankful to you.

 

(ideal tutorials would be able to work on VS2012,has to be C++, i don't care which library it uses, i prefer openGL, but i'll take DX without hesitation. thanks again.)


PARTNERS