Jump to content

  • Log In with Google      Sign In   
  • Create Account

Assassinbeast

Member Since 24 Sep 2012
Offline Last Active Jun 17 2013 04:30 PM
-----

Topics I've Started

How important is the iostream in gamedev?

15 January 2013 - 10:01 AM

Hello folks :-)

 

I just wanna ask how important it is to learn/master the basics of iostream in c++.

 

eg:

 

cin.fail

cin.good

cin.clear

cin.bad

cin.putback

cin.get

cin.getline

cin.eof 

 

and all that bullshit.

 

for me, its kinda hard to remember because i never use it when i make games, and i never use it when i test my own code (only cout and cin), but sometimes when i read books, they use it. So its getting  hard and frustrating to remember how the iostream is made and when the states are set.


is class templates made in gamedevelopment?

06 January 2013 - 01:30 PM

Hello smile.png

 

I just learned templates, and i know quite abit right now.

 

So i just wanted to ask if there is any situation where you want to make your own class template. Becasue vectors already exist, and i cant really imagine when you should even need to define your own class templates.

 

But i know defining your own function templates are very useful in alot of kinds situations


Made my own small GameEngine, but how do i reuse it fast?

03 January 2013 - 02:56 PM

Hello.

 

I just made my small gameengine in c++ with sfml, where i have made menus, butttons, gamestates and such.

There are a lot of different files, and some images.

 

So i how do i reuse it when i have to make a new game?

Should i just copy the header files,cpp files, image folders etc into my new project?

If so, that would be tedious like to link every project with sfml... unsure.png

 

Btw, I am using microsoft visual studio express 2010.


How do you check collision against 1000x1000 objects?

02 December 2012 - 04:16 PM

Hey, i just need some information on how to check collision if theres 1000 objects on the field.
And all 1000 objects are enemies to eachother.

So, do i for example have to make two for loops like this?:

[source lang="cpp"]for(int i = 0; i < objects.size(); ++i) //objects.size is the size of the vector(if i use that) for(int j = 0; j < objects.size(); ++i) collision(objects[i], objects[j]);[/source]
But thats 1000x1000 = a million loops in a single statement Posted Image

So, i just want to know if thats how you do it... cant see any other way of doing this so far Posted Image

How do i load files from the documents folder?

10 November 2012 - 04:47 PM

Hey guys.

How do i load from files in the documents folder on any computer?
I am making a game that have a highscore.txt file.

So far, how i load and save the highscore.txt file is kinda this way.

[source lang="cpp"]int score = 0;int highscore = 0;std::ifstream inputfile;inputfile.open("highscore.txt");inputfile >> highscore;inputfile.close();/*Play the game (gameloop)*/if(score > highscore){ std::ofstream outputfile("highscore.txt"); outputfile << score; outputfile.close();}[/source]

But the problem is when i make an installer for my game, then i have to put the highscore.txt file in another folder (e.g my documents folder) than my original folder where all the images, dlls are. Otherwise i cant save my new highscore (only load) because the c: drive is protected and windows wont allow to edit it.

Ive tried to write something like this:

[source lang="cpp"]inputfile.open("C:\\Users\\Danny\\Documents\\highscore.txt");[/source]
It works, but "Danny" is my name and is of course not the same name as other peoples computers.

So what kind of code should i use/write to make it able to load and save in the highscore.txt file on the documentsfolder on any computer?
If u can help me (and if its gonna be a hard task), please, cut it in paper for me (post the code Posted Image ), because im a big noob when it comes to new libraries or low-level programming or anything like that

Thanks alot!!! Posted Image

PARTNERS