Jump to content

  • Log In with Google      Sign In   
  • Create Account

lride

Member Since 16 Aug 2012
Offline Last Active Jan 18 2014 12:59 PM

#5064629 Entity-component systems and animations

Posted by lride on 24 May 2013 - 04:22 PM



If I implement that, the code will work just fine, but I feel like I'd have broken some golden NO-OBJECTS rule of entity design. I've implemented animations in other fashions but they don't have quite the capability --- I've not been able to put multiple animations on a single altas, or have animations where the frame width and height could change.

 

I don't understand why you can't have a resizable container and objects inside a component. 

Containers and objects are good way to encapsulate and store data.

Raw data doesn't mean that you only can have primitive types in a component. What you want to stay away from is having lots of functions in a component. That's system's job.

Use a vector to store each frame.




#5046293 Calling member function via nullptr

Posted by lride on 24 March 2013 - 01:48 PM

class A{   
void say(){std::cout<<"hi";}
};
 
int main()
{
    A * a=nullptr;
    a->say();   //no crash, works fine
}
 

Is this undefined behavior?




#5046136 Are pointers initialized to nullptr in a vector?

Posted by lride on 23 March 2013 - 11:26 PM

class A{...};

int main()
{
	std::vector<A*> vec;
	vec.resize(10);
	std::cout<<(vec[9]==nullptr); //prints 1
}







 

 

I want to make sure this happens on every system.

Are pointers initialized to nullptr?




#5023578 Version control for begginers

Posted by lride on 20 January 2013 - 12:57 PM

Git is really simple to use once you learn it.

I liked this tutorial 




#5018256 Sprite Animation - SFML

Posted by lride on 06 January 2013 - 12:07 PM

To me your way should work because even though the animation stops when the up key is released, it should start again because the left key is being pressed.

But this is how I implemented SFML animation in my project

It's simple. Don't start the animation only if(sf::Event::keyIsPressed).   Start the animation always even though the key is not pressed and stop it later if key is not pressed

Below code is in the main loop

 

        animation.start(); //Just start the animation
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
           ....
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
             ....
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
               .....
        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
                 .....
        else
            animation.stop(); //   -Stop the animation when keys are not pressed

 

        ....

        animation.update(dt); //   -Animation only gets updated when the animation has not been stopped




#5016818 File input/output in C++ Question

Posted by lride on 02 January 2013 - 02:18 PM

The program will look for the file in the executable's directory.

You can't really make your level files invisible, but you can hide them by packing all your level files in a "level" folder and placing the folder in your executable's directory.

Then you can load the levels like

 

loadLevel("level/level1.txt");

loadLevel("level/level2.txt");




#5011165 Game from Scratch ? C++

Posted by lride on 15 December 2012 - 10:12 PM

But still on basics


If you are still on basics, you can't make a game.
Learn the language first.


#5008941 using 2d std::array

Posted by lride on 09 December 2012 - 07:44 PM

You can just make a std::array of std::arrays. Ex: std::array<std::array<int, 5>, 10>.

5 is the row and 10 is the column?
So I can access each element by
array[row][column]?


#5008540 C++ Job Interview Books

Posted by lride on 08 December 2012 - 11:42 AM

Cracking the Coding Interview is a good book


#5006790 New is SLOW!

Posted by lride on 03 December 2012 - 03:33 PM

I am a noob here. So I have a noobish question. I just received a downvote for this post. Is there a reason for this, and something I can avoid in the future? Because I don't like offending people or posting inappropriate content.

+1 to compensate for that downvote.
It is an obvious fact that new is slow, so someone could've thought your question was ridiculous especially when you caught attention of people by capitalizing SLOW!


#5003676 vector iterator not incrementable

Posted by lride on 23 November 2012 - 11:17 PM

Never mind, I found a solution


#5003504 Change the compiler of c++ 11

Posted by lride on 23 November 2012 - 08:20 AM

Put std::cin.get() (maybe one more) at the end of your program to pause.


#5002471 priority_queue big o notation with vector and deque

Posted by lride on 19 November 2012 - 04:21 PM

What's the big o notation for push() and pop() in priority_queue with vector or deque as its underlying container.
I can't find this anywhere.
I'm guessing linear complexity at worst for push() because it has to search for right place to insert.


#5002208 Best OpenGL books for beginners (C++)

Posted by lride on 18 November 2012 - 08:44 PM

Look at this one - OpenGL SuperBible. It's brilliant. I'm reading it now and I like it so much.

Be careful about this book. This book teaches OpenGL wrapper library, not the actual OpenGL itself.
I'm waiting for this book to come out in next February


#5002154 Impotant! Books to start learning video game programming ! I need it...

Posted by lride on 18 November 2012 - 05:25 PM

You will need a lot of time and patience, but after a 5+ years, you should be able to program almost everything you wish (but be aware that the time needed to do it will still be in years).


5+ years, That's ridiculous. I started programming not much older than him and I picked up C++ in a year, a year later I was writing full blown 3d games in C++. My advice is skip C# and spend a while getting to know C++ and you should be able to program almost anything in 2+ years if you work hard.


I totally agree with this. I'm a HS sophomore and taught myself the whole C++ and made my first game over the last summer.




PARTNERS