Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mastodona7x

Pages: [1] 2
1
Graphics / Re: Help with RPG inventory system (solved) Thanks!
« on: July 16, 2012, 12:57:39 pm »
I just borrowed "C++ for game programmers" by M J Dickheiser from the libray, I too started with learncpp.com and this book goes over some of that stuff in far more depth and all from the point of view of developing games...seems interesting (if a little bit daunting)...I also borrowed "AI game engine programming" which looks good too and has real world examples and AI ideas/code snippets for all different game genres (racing, RTS, RPG, FPS etc etc etc) which makes it quite an interesting read so far.

2
Yeh got me first ever time I tried, now I have a folder for "images" "sfx" "fonts" etc etc in the root of each new project I make :)

3
Graphics / Re: Loading a map of a file
« on: July 14, 2012, 02:39:07 pm »
I just realised my above post really doesn't answer your question but maybe instead of worrying about loading/saving just work out some more basic ways to do things if you are just begginning like I am? Don't try to walk before you can crawl sort of thing :) Make a basic grid based game to start with then build on what you have learned.

4
Graphics / Re: Loading a map of a file
« on: July 14, 2012, 02:35:54 pm »
game_maker I have very little knowledge of c++/sfml but one of the first games I made was a battelships game, which is the same sort of idea.

I made a vector<vector> for the map and that stored values for different things at each coordinate (0,4 might have had a value of "2" for example which translated to part of a ship, or value of 1 for open water, etc...then just loop through the vector to output whatever each value translates to to the screen, similar to how you've been doing.

for example:
Code: [Select]
//create empty map array
vector<vector<int>> player1map; // create 2d vector (matrix)

 // map array size xsize * ysize filled with 0's
        player1map.resize(xsize, vector<int>(ysize,0));

the above makes a vector of ints and xsize and ysize are the x and y size for the grid (might be 10*10 for example), first it fills them with 0's but you can obviously do what you like there,

Code: [Select]
for(int y=0; y<ysize; y++) // y-wise (number of rows)
    {

for(int x=0; x<xsize; x++) // fill in x-wise
        {
            switch (maparray[x][y])
{
case 0: // fill "square" with empty space / water
///display empty water graphic here
break;
                         }
         }
   }


Its very basic and not reading from files etc but maybe it'll give you something to work with I don't know.

5
Graphics / Re: Loading a map of a file
« on: July 13, 2012, 11:34:42 am »
Well for some reason the function he passes the string[] in to sees the string[] as a char and not a string so it won't compile...

6
Graphics / Re: Are shapes even drawable in 2.0...?
« on: July 13, 2012, 11:31:53 am »
Yeh just clear first, then draw, then display...if you clear  the display then display it what were you expecting to see ....seems pretty obvious even to me  :o ;D

7
Graphics / Re: Loading a map of a file
« on: July 13, 2012, 12:05:47 am »
I can't even get it to compile never mind freeze? Im so new to C++ I could be wrong here but why are you making line a string then using [] on it? Wouldn't it be better to make it a vector and push each item in to that?

ifstream In("data.dat");
    vector v;

    cout << endl << "Read data from file" << endl;
    while ( ! In.eof() )
    {
       getline (In, str);
       v.push_back(str);
    }


the compile error I get is:

imageManager.LoadImage(line[col], id);

1>Level.cpp(97): error C2664: 'ImageManager::LoadImage' : cannot convert parameter 1 from 'char' to 'const std::string &'
1>          Reason: cannot convert from 'char' to 'const std::string'
1>          No constructor could take the source type, or constructor overload resolution was ambiguous

8
Graphics / Re: Loading a map of a file
« on: July 12, 2012, 12:20:14 pm »
I did this for a simple battleships type game and yeh just a for loop to go through the txt file, though I used a "switch" statement instead of lots of if statements, seemed neater somehow but same end result!

for (int row = 0; file.good(); ++row) {
    std::string line;
    getline(file, line);
    for (int col = 0; col < line.length(); ++col) {

switch(line[col])
{
case '1':
            // save image for ID of 1
break;
case '2':
            // save image for ID of 2
break;
}
        // .... so on and so forth
    }
}

9
Graphics / Re: Anti-Aliasing of Text
« on: July 12, 2012, 12:12:49 pm »
Maybe I'm missing something but why can't you just use a really simple looking font?? Plenty of free pixel-looking fonts here for instance?? http://www.dafont.com/bitmap.php, download, stick it in a /fonts/ folder in your project dir

sf::Font font;
     if (!font.loadFromFile("fonts/somesimplefont.ttf"))
         return EXIT_FAILURE;

10
Graphics / Re: Help with arrays, and crashing (RPG inventory system)
« on: July 12, 2012, 12:11:22 pm »
Go easy on him guys, I'm a fellow newbie to C++/sfml but always found the people on here really nice and helpful!! And in the IRC chat too...got all my problems fixed without resorting to insults :) Hope you get your game going it looks like turning into a nice little project to me :)

11
Graphics / Re: sprite being drawn twice on top of each other?
« on: July 08, 2012, 03:21:28 pm »
OK I AM STUPID!!!  ;D Thanks to DrSulfurious in thew chat room for pointint it out (its just because I was drawing the bomb in the i loop so it was being drawn i times in the same place...I've moved the bomb drawing into a new for loop outside the main i for loop and its all fine now....I didn't get much sleep last night OK  :o ;D ;)

12
Graphics / Re: sprite being drawn twice on top of each other?
« on: July 08, 2012, 02:31:44 pm »
And some code if it helps....

spacebar event
if (event.type == sf::Event::KeyPressed)
    {
                if (event.key.code == sf::Keyboard::Space)
                {
                        if(allowBomb==1)
                        {
                                Bomb bomb(-32,-32,96,96,player1.getPosition().x,player1.getPosition().y); // -1 and 34 so collision rect overlaps/collides with vBlocks next to bomb
                                bomb.setTextureRect(sf::IntRect(0,0,32,32));
                                bomb.setTexture(bombTexture);
                                vBombs.push_back(bomb);
                                fuseSound.play();
                                allowBomb=0;
                        }
                }
    }
 

this is the main game loop where the bomb is displayed (most of this is irrelevant to this but for the bomb parts)...I just thought it odd the blocks are displayed in a loop too
Code: [Select]
window.draw(vBlocks[i]) and they dont appear to be rough round the edges like the bomb is?
for (unsigned int i = 0; i != vBlocks.size(); i++) {

                        if(player1.isCollidingWith(vBlocks[i])){
                                player1.collide(vBlocks[i]);
                        }

                for (itBomb = vBombs.begin(); itBomb != vBombs.end(); itBomb++)
                {      
                        if(itBomb->getBombTimer()>1){
                               
                                if(itBomb->isCollidingWith(vBlocks[i])){
                                        //check if indesctructable
                                if(vBlocks[i].isDestructable!=true)
                                {
                                        //otherwise remove block
                                        vBlocks.erase(vBlocks.begin()+i);
                                }

                                //check if player in blast
                                if(itBomb->isCollidingWith(player1))
                                {
                                        cout<<"player 1 is dead";
                                }

                                }
                                if(itBomb->getExploded()==false)
                                {
                                        boomSound.play();
                                        itBomb->setExploded();
                                        allowBomb=1; // allow the laying of another bomb now
                                }

                                if(itBomb->getBombTimer()>2)
                                {
                                        itBomb=vBombs.erase(itBomb);
                                        break;
                                }
                       
                        }else{
                        window.draw(*itBomb);
                        }
                        }
                        window.draw(vBlocks[i]);
                }

                window.draw(player1);
                window.draw(sprite); // this is a test bomb...remove!
                window.display();
 

13
Graphics / sprite being drawn twice on top of each other?
« on: July 08, 2012, 02:26:00 pm »
Hi all, I have a strange problem where in my bomberman type game I'm making, when you lay a bomb, it appears very rough around the edges. Testing in photoshop it looks like the png is being layered on top of its self twice on the window.draw(*bomb). I can tell this because the flame which is semi transparent is very dark compared to just manually placing the bomb on the field. (See pic please - I've enlarged this to make it clearer).
Has anyone come across this before and/or could suggest why this might be happening? I have tested and know only 1 bomb is being layed when space bar is pressed, so why the double texture?

Note the left bomb is a sprite I manually created and placed , the right one is one "layed" in the game by pressing spacebar, and as I say it is only 1 object...


14
Graphics / Re: Check to show sprite function
« on: July 08, 2012, 01:00:43 am »
In the example above why isn't it [4][3] instead of [3][4]?

15
Graphics / Re: Texture won't display when loaded from within a class?
« on: July 07, 2012, 08:18:38 pm »
I hear inheriting from sf::sprite is not a good idea! But it sort of all works now anyway, thanks for the help guys :)

Pages: [1] 2