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.


Topics - magneonx

Pages: 1 [2] 3
16
General / Inheriting from structs?
« on: August 25, 2013, 07:59:21 pm »
Hello i just got some problems and I got confused.

I have POD that handles typical attributes for a game entity.So I presented it this way:

#include<iostream>
#include<string>
using namespace std;

struct Attribute
{
    string directory;
    string name;
};

struct TileAttribute : public Attribute
{
    int cost;
};

struct AssetAttribute : public Attribute
{
    int cost;
};

int main()
{
    Attribute * attribute = new TileAttribute;
    attribute->cost; // no such thing as cost in TileAttribute; error
// WHAT's the big deal if I use "."? I am asking why can't I access cost? I think I am missing something here
// Thanks for the correction anyway.
    return 0;
}

 

I recreated this snippet using this code and I can't figure out how am I suppose to inherit just variables on deriving structs? Is this even possible? I have a container for attribute and I don't want creating a separate containers for two.  Well I could save myself some troubles if I could write this as a full pledge class but I just want handler that handle values distinct to tiles and asset so I just used POD.

How can I fix this?

Thanks for your help!

17
General / Steering behavior problem.
« on: August 21, 2013, 08:14:45 am »
Hello! I am reading this tutorial:
http://gamedev.tutsplus.com/tutorials/implementation/understanding-steering-behaviors-seek/

So how do you truncate? I did my homework and I can see all that is there is outputting it. There are some, that truncate a value but I don't even know if that is what I need. I don't need outputs. So how do you do this and why do I need it? Is there SFML or C++ function that I could use?

Also I have a problem, action script is too abstract, what do you mean by scale by? I am not a great fan of functional programming. I don't what scaleBy means in mathematical formula. If you can just give me formula scaleBy and truncate that be great.

Anyway here is action script of that tutorial I am stuck at truncate and scaleBy. I am sorry for my shortcomings when it come to this thing but this is pretty much wasting my time deciphering a hieroglyph.

This code is not exactly how I move things in SFML and I am stuck at truncate and scaleBy.

public function truncate(vector :Vector3D, max :Number) :void {
                        var i :Number;

                        i = max / vector.length;
                        i = i < 1.0 ? 1.0 : i;
                       
                        vector.scaleBy(i);
                }
               
                public function update():void {
                        target = Game.mouse;
                       
                        steering = seek(target);
                       
                        truncate(steering, MAX_FORCE);
                        steering.scaleBy(1 / mass);
                       
                        velocity = velocity.add(steering);
                        truncate(velocity, MAX_VELOCITY);
                       
                        position = position.add(velocity);

                        x = position.x;
                        y = position.y;
                }
 

18
Hello! I just wanted to know more about subsumption architecture? Do you know some topics or articles I can read on? I wanted to look for some articles that are only related on video games

Actually, I wanted to use FSM for my experimental game. I don't want go on details here but I may give some couple of things that I want my game actors to do:

My game should have AI Path Finding which I have done,
My game spawns civilian to a particular point, the primary objective of my game is the player has to escort this to my ship safely
My game has enemies and will "harass" the player for bringing this civilians to my spaceship.
My game has a certain time so the AI has to react base on it also

And no, enemies on the game don't have resources, they just spawn randomly on random time intervals.

I don't know if FSM can satisfy this or using advance fsm like subsumption? I hope I get things straight for now. If so I'll be needing articles, books, personal experiences, to guide me in writing up this AI.

If I miss something and fully misunderstood or disrespected AI programming in anyway please let me know.
Thanks for your enlightenment!

19
Hello, in my game I have this memory model by which I compose a grid and store the data structure Tile dynamically with shared_ptr in a 2d vector.

There are times that in my game there are certain routines that have to be done and if that routine fails. My game exits. I use exit() function to do this.

How can I guarantee that all resources are freed and released?

I haven't tried to read the C++11 manual for this, and even if I do, I might not understand it very well.
Which one should I use best for my situation?

Thanks

20
Hello it seems my post has been confusing readers( I might even deter others from helping me). SO I edited the orignal post.

I no longer want movement through vector normalization, I am not totally verbose in math, what I mean is, going from point to another point using vectors. Because it works great at first, but there are instances that makes the AI Path Finding don't look nice in the game I am making.

What I want now is moving horizontally and vertically without even normalizing the vector. Is there anyway I could do it? Also, I don't have any means to detect whether the next tile in question is on left, right, top, bottom of the sprite. I heavily rely on delta of sprite position to target position( by subtracting sprite position to target position) to give me the sign whether to move the sprite horizontal or vertical.

 Just try to imagine you are moving sprite using keyboard, but this time the input is the position of the next tile. Usually in keyboard you move your sprite at ( -10 , 0 ) if you wanna go left etc. This time it's different it has a mind of its own the only input it needs is the position of its next adjacent tile.

for example:
My Sprite is on position( 60.0f , 60.0f )
the generated path is:
60.0f , 120.0f // go down
60.0f , 180.0f // go down once more
120.0f , 180.0f // go right

I have to go to the path 120.0f, 180.0f. That's my input for my sprite on how it going to move around. I just gave it coordinates were to go. My question is, How can I go from (60.0f , 60.0f) to (60.0f , 120.0f) at the first loop up until the last tile at( 120.0f , 180.0f )? I don't like normalizing vectors anymore, my code actually works using that but there are times it cuts corners when my sprite was trapped between 2 tiles when I issued a new order (I haven't fixed that yet but as soon as I finish this one).

I hope it really clear things up.
This problem has been bothering me eversince, I could not sleep and my sleeping pattern is heavily disrupted by this one.

21
General / Problem in moving sprite to point A to point B
« on: August 08, 2013, 09:57:43 pm »
Hello guys! I have actually posted similar thread but I will a post new one. I have finally made my sprite to move from point a to point b with AI Path Finding. The problem is that my sprite jitters like crazy at a certain tile and it takes a while before it gets into the next tile when it jitters, you know it goes back and forth in small area so fast it seems its like shaking. I know for the fact in could not resolve its x and y position by smallest fraction. I don't know what I am missing here.

The manner by which I move the sprite is I use normalization of the vector. I found the movement cool. But I know that calculation messes it up.

This is just a prototype so stop lecturing me on conservative way on writing things. I am just used on seeing things in full scope rather than abstracting it in code.

This is the function which generate the path from the AI path finder
void MovableWorldObjects::getPath()
{
    _Iterator end_iter   = closedList.find( endTileID );
    _Iterator start_iter = closedList.find( startTileID );

    Tile * t;

    t = closedList[ currentTileID ];
    path.push_back( t );

    while( end_iter != start_iter )
    {
        t = end_iter->second->getParentTile();
        path.push_back( t );
        end_iter = closedList.find( t->getTileID() );
    }

    std::reverse( path.begin() , path.end() );

    if( ( c + 1 ) < path.size()  )
    {
        spriteCurrentTile = path[ c ];
        spriteNextTile    = path[ c + 1 ];
        cout << "from getTile()--the next selected tile is : : " << spriteNextTile->getTileID() << endl;
    }

    /*
    cout << endl << endl;
    cout << "Path is : " << endl;
    for( size_t i = 0; i < path.size(); i++ )
    {
        cout << path[ i ]->getTileID() << " " << endl;
        int x = path[ i ]->getTileGridPositionX();
        int y = path[ i ]->getTileGridPositionY();
    }
    */

}

This is my function that tells the sprite to move and follow the path

void MovableWorldObjects::moveToDestination( float e )
{
    float velocity = 150.0f;
    float tilesize = static_cast< float >( tileset->getTilesize() );

    if( _isPathFound )
    {
        if( ( c + 1 ) < path.size() )
        {
            targetPosition.x = spriteNextTile->getTileGridPositionX() * tilesize;
            targetPosition.y = spriteNextTile->getTileGridPositionY() * tilesize;

            spritePosition.x = perspectiveX;
            spritePosition.y = perspectiveY;

            //cout << "Sprite moving at : " << movex << " x " << movey << endl;

            delta.x = targetPosition.x - spritePosition.x;
            delta.y = targetPosition.y - spritePosition.y;

            float dist = sqrt( ( delta.x * delta.x ) + ( delta.y * delta.y ) );
            delta /= dist;

            float distMoved = e * velocity;

            float movex = spritePosition.x + delta.x * distMoved;
            float movey = spritePosition.y + delta.y * distMoved;

            perspectiveX = movex;
            perspectiveY = movey;

            if( spritePosition.x == targetPosition.x && spritePosition.y == targetPosition.y )
            {
                spriteCurrentTile = path[ c ];
                spriteNextTile    = path[ c + 1 ];
                c++;
                cout << "moved" << endl;
            }
           
            WorldObjects::setSpritePosition( movex , movey );

        }
        else
        {
            _isPathFound = false;
            cout << endl << endl;
            cout << "==================================" << endl;
        }
    }
    else
    {
        c = 0;
    }
}
 

Also I am quite a little bit confuse regarding the top left coordinates, I have set sprite origin to its center.
and I wanted to check if the sprite move to the "Center" of the tile. If I divide the target by 2 it doesn't get the right path. So I am basing the checks on the top left not on the center. I need this because I have to rotate the sprite from tile to tile.

I been doing this for a very long time. For no reasons at all I could not find my shortcomings in this code. I am struggling, this is suppose to be very easy. I could grasp the algorithm very well. I can't refactor or restart again from scratch because I can't get over this thing. I just can't give up. I could not even sleep and concentrate on other things, personally, this really bugs me.

If you can help me that'd be great and you could free me from my worries.

22
Hello! The title says it all,

But to give some few tips for this is that:

first, I have made a Tileset, which is a container of class Tile where I made a 2d vector of shared_ptrs for a Tile. Tile contains info on cost that constitutes the formula of F = G(n) + H(n).

second, the shortest path are stored for in a vector named closedList which is a vector of Tiles*.
So this is where I am going to take the shortest path.

It seems that, the web is full of tutorials on AI Path Finding, I have implemented mine as well, but does give constraints on actually moving the sprite to from point A to point B? I just followed the exact algorithm so I could make sure this is right, and it was right, or should I just reprogram my AI code to accomodate to such requirement of actually moving the sprite from point a to point b?

Thanks!

23
General / Laptop get hot when running a simple tileset
« on: July 31, 2013, 11:36:10 am »
I just wanna ask if this is normal? I have a quad core Intel i7 and I have GT640m GDDR3 2gig VRAM. I am running my program on my laptop. and each core has 59-73C of temparature, I am just running a very simple 2d tileset. Is this a fault in my part or my laptop maybe? I can play Torchlight II with temps at 60-70C degress,  and crysis at 70-80C and this is just a simple 2d tile sprite.

I am just afraid this will go hotter if I put more in my game screen. Is this normal? Or just my program sucks.
Thanks!

24
General / failed to create the font face
« on: July 26, 2013, 03:03:05 am »
Hello! I have a problem regarding my game prototype. It could not load the font face. I do not intend to put the entire code and what went wrong, I just have simply recreated a simple SFML code that loads font and still get the same error. I never had this error once.

What causes this??? I need help.

25
Hello! I am having problems with missing .dlls.

First I have problems with compiling SFML, it says missing SFML .dlls. I tried to put it on Environment Variables: Path and still nothing. I don't like copy-pasting needed dlls to project folder yet and its cumbersome when making simple prototypes.

Second using THor, I have downloaded it from the repository and my cmake says I have missing dll files typically from my MinGW compiler. It looks for the dll file name libgmp-10.dll. Again, adding it to envi still produces the same result. I have it on my mingw bin folder.

I don't know what I am missing?

Note:
I have perform factory reset on my laptop and have backup the codeblocks folders from %APPDATA% for my user defined settings alongside with my library configurations. Also I have perform backups on my libraries as well. So I just installed codeblocks on the same folder, pasted the MinGW on the same folder, and so is the libraries. Maybe that causes the problem???

I as I have tested, I also added both to user-define variables and system variables

I really need help.

26
General / How to make your game assets on a single file?
« on: July 07, 2013, 04:23:31 am »
Hello! I just notice on some games like Torchlight II, they have their game files on .PAK. I want the same thing too, because I don't like my .pngs scattered on a folder. How can I make it like that?

Is SFML capable of loading those resource say on a compress file??? Of course, this could make the game load a lot longer but I just want my game folder spick and span. At least though its irrelevant at some times.

Thanks!!!

27
General / [SOLVED]I have problem in a 2d vector of class Tile
« on: July 02, 2013, 03:59:56 pm »
Hello Guys I am going to implement dijktra's algorithm and I really need to show up some walkable and unwalkable tiles on screen. I am having a great problem doing this because, every time I draw the tile nothing appears. I suspected somehow that the implementation I made in loading that vector is wrong and that it loses reference as soon the loop ends. I badly need help on this one..

This is how I populate the grid with walkable tiles as the default tileset
    shared_ptr< Tile > tmp;

    for( int y = 0; y < grid_height; y++ )
    {
        tset.push_back( vector< shared_ptr< Tile > >() );

        for( int i = 0; i < grid_width; i++ )
        {
            tmp.reset( new Tile( "walkable.png" , 50 ) );
            tset[ y ].push_back( tmp );
        }
    }
 

this is how I draw it.

void Grid::populateGrid()
{
    int dist_y = 0;
    int dist_x = 0;

    for( int y = 0; y < grid_height; y++ )
    {
        for( int i = 0; i < grid_width; i++ )
        {
            tset[ y ][ i ].get()->setTexture( wTile );
            tset[ y ][ i ].get()->setPosition( dist_x , dist_y );
            dist_x += tilesize;
        }

        dist_x = 0;
        dist_y += tilesize;
    }
}
 

28
General / Why is it there is no sprite.setOutline(thickness, color);?
« on: June 29, 2013, 10:44:48 am »
I somehow need this kind of functionality for my collision detection and developers mode.

29
General / Need help on working with times
« on: June 27, 2013, 05:01:38 am »
Hello! I am writing a game, I would like to know the maths and the terms relating on working with times.

For example, a character reloads its weapon for 1.25 seconds, spawning enemy every 10 seconds, spawning for 3 seconds before game start, etc etc what is the math behind this?

Can you teach how this is done, at least some formula will do. I am not particularly good in numbers so...

Also, I am using the technique in fps where it remains constant all through out regardless of the CPU speed.
So I am rendering using that.

Thanks.

30
Window / Problem with checking if left mouse button is pressed
« on: June 25, 2013, 06:52:26 pm »
Hello I need help regarding my problem.

We know that there are 2 ways on how to listen if a mouse button was pressed:

1st you check it using poll event
2nd you can use the sf::Mouse::isButtonPressed or something like that

If you will ask, I have a sprite that fires a machine gun. So it had to be holding the button down and it fires rapidly. I also have bullet sprite stored inside vector so I can manage it easily.

One thing I have notice is that if I click the mouse button, just ONE click, it had created 70+ pointers for my bullet sprite.

I have tried the poll event. It works great!! 1 bullet per one click, but I cant hold the mouse button.

Is there anyway I could achieve my desired behavior? SHould I check for the rate of fire?
I need a gun that fires either you click the button or you hold it.

Thanks!

Pages: 1 [2] 3