Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 627 posts ]  Go to page Previous  1 ... 59, 60, 61, 62, 63  Next
Author Message
 Post Posted: October 6th, 2017, 10:31 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 487
Location: Idiot from northern Europe
chili wrote:
DOD is interesting, and can be useful, though I'm not sold on full-JBlow style DOD.

At any rate I think it will be a good thing to study and get ideas from.


Good to hear you're not totally against it :D I want it to be chili approved!

Could you please tell me why OOP is the shit in your opinion?
Right now, OOP is the only way I've every programmed. I like it, but I'm not experienced enough to know if/why it's better than other ways of programming.
I know my teacher dislikes OOP and I'm sure I'll get to hear why he dislikes it. I feel like it'd be good to hear some input from you on why it's good so I get to hear both sides.

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: October 7th, 2017, 5:40 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
If your teacher is against OOP, are they for something like functional or procedural ( functional in the sense that data is immutable and functions do work and return new data, procedural in that functions are like subroutines, just organization and code reuse mechanisms ).

My personal opinion, though not asked, is OOP is about clarity of intent, code organization and encapsulation. A class ( as well as a struct in C++ ) stores state and behavior. In procedural languages like C, you have a struct for state and functions/procedures for changing behavior of the program by passing in an object. As far as C++ goes, OOP allows for safer resource management by using constructors and destructors. Managed languages like C# and Java also considered OOP languages handle resources for you by randomly (I'm sure there is an algorithm used ) releasing memory that has gone out of scope ( maybe reference counted? ). I don't know how other languages such as interpreted ones like Python or JavaScript handle resources ( I've seen a YT video by someone saying JavaScript is also garbage collected like C# and/or Java ).

Most of the things I've heard against OOP is the insane amount of boiler plate to accomplish the same task in a procedural language such as C. I tried an experiment with C a few months ago by rewriting most of the chili framework in C. It was a nightmare for me. I love how C++ allows for function and operator overloading, C doesn't have this. This means I can use the same function name 50 times as long as the parameter list is different for each one. This means that the interface I use as the end user is simplified.

Data oriented design would be helpful to learn and probably allow for greater flexibility in your applications. The biggest advantage is being able to write the program and keeping the data separate. This allows you to change the data thus changing the behavior of your program without having to recompile or reducing the number of times you recompile anyway. There's also the separation of responsibility between developers and designers. This allows multiple teams to work on the same portion of the project without stepping on the toes of each other.

I could have all this wrong, but that is what is going through my head, so I'm interested to hear why teach is against OOP really.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: October 8th, 2017, 12:10 am 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 487
Location: Idiot from northern Europe
We'll still be programming in c++. Just Data oriented design instead of OOP. Not quite sure what this means yet, all I've done so far is read this article

http://gamesfromwithin.com/data-oriented-design

From what I can tell it's different from procedural and functional.

Teacher said we'll still use classes, just not OOP.

The biggest upside of DOD from what I can tell so far is that it's supposed to be faster which I guess is a big deal in game dev.

And yeah like you mentioned with separating logic and data I think that might be a big thing too. Like having text files which the designers can mess around with to change stuff in the game without having to touch any code.

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: October 8th, 2017, 5:09 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Hmm, perhaps I got confused on what was meant by Data Oriented Design. I was thinking more along the lines of putting data in external files ( like a text file ) and having the behavior only in code.

The information in the article you posted has been discussed here on the forums a few times actually. Putting your data in say an array and a single interface to manage the array. This allows for significant performance boosts because of data locality and the use of SIMD instructions.

If I ever get over my mental code block, I'll have to make a little demo that demonstrates this in some fashion. Of course you can do the same. Make a demo of say 10,000 elements or 100,000 elements all doing something different on screen. Make two versions, one uses OOP where each element is an object in an array and the other is a single class of arrays of data. Say an array for the X positions, one for the Y positions, one for the X velocity and one for the Y velocity.

You'll really be able to see what the author of the article is talking about the higher you go, but there will be a limit.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: October 13th, 2017, 1:01 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 487
Location: Idiot from northern Europe
^ Yeah I still don't understand it, kinda put leadning about DOD on the backburner for now since we're not there yet and I have other stuff to work on at school :)

Finished first assignment for this course.

Loaded a 3d world and a model sun into the engine.
Made a sun dazzle effect for when the camera is looking towards the sun. Basically a white quad covering the screen and its alpha increases the more directly you look towards the sun.
Also created a lens flare, this was tricky but think it came out alright.

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: October 13th, 2017, 2:33 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
^^
I've seen a video from JBlow as chili calls him where instead of creating an array of Enemy objects, he creates a struct called Enemy and stores the count and arrays inside the struct. Since in your game loop you'd normally do something like:
Code:
for(auto &enemy : enemies)
{
     if(enemy.IsAlive())
          enemy.Update(deltaTime);
}

Instead, you'd just call enemy.Update(deltaTime) and that one function would iterate over the enemies.

Code:
class Enemy
{
public:
     Enemy( size_t Count );
     void Update( float DeltaTime );
private:
     std::vector<float> px, py, pz;  // Positions
     std::vector<float> vx, vy, vz;  // velocities
     // vector of bool is overloaded to pack bits which saves space, but slower to access so use
     // unsigned int instead
     std::vector<unsigned> isAlive;
};
Enemy::Update(float DeltaTime)
{
     for(int i = 0; i < count; ++i)
     {
          if(isAlive[i])
          {
               px[i] += vx[i] * DeltaTime;
               py[i] += vy[i] * DeltaTime;
               pz[i] += vz[i] * DeltaTime;
          }
     }
}


As I stated before, this could also allow for SIMD instructions to be used more efficiently allowing you to handle 4, 8 or 16 updates at a time depending on which version of SIMD instruction set is used. Of course if you're the one writing the code you'd want to check if the users CPU can handle those instructions.

Even without the SIMD instructions, you can be sure that the data is contiguous since each element is in an array/vector so fetching data is going to be really fast.

If the syntax kind of looks familiar to you it kind of resembles how you used the Manager classes in your space shooter.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: October 15th, 2017, 1:22 am 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 487
Location: Idiot from northern Europe
^ that sounds pretty clever to me


I want to do a game project outside of school whenever I have some spare time. Want to try and to a simple version of megaman x. felt like a good idea at first but already starting to regret it :D Today all I did was editing a sprite sheet and tried to load the animations.
Thing is, there's a looooot of sequences. I'm at 21 now and that's just for moving to the right. There will probably be a few more added too.
The sequences also don't have the same amount of frames so I can't loop through them in the constructor so atm it's a whole lot of this

Code:
    enum class Sequence
    {
        StandingRight,
        RunningRightStart,
        RunningRight,
        JumpingStart,
        JumpingUp,
        JumpingDownStart,
        JumpingDown,
        JumpingEnd,
        DashingRightStart,
        DashingRight,
        BusterRight,
        RunningBusterRight,
        JumpingBusterStart,
        JumpingBusterUp,
        JumpingBusterDownStart,
        JumpingBusterDown,
        JumpingBusterEnd,
        DashingRightBusterStart,
        DashingBusterRight,
        SlicingRight,
        JumpingSlicingRight
 
       
    };


and this

Code:
    animations.emplace_back(Animation(0, 0, 100, 100, 4, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(400, 0, 100, 100, 1, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 100, 100, 100, 10, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 200, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(200, 200, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(400, 200, 100, 100, 1, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(500, 200, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(700, 200, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 300, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(200, 300, 100, 100, 4, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 400, 100, 100, 1, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(100, 400, 100, 100, 10, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 500, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(200, 500, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(400, 500, 100, 100, 1, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(500, 500, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(700, 500, 100, 100, 1, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 600, 100, 100, 2, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(200, 600, 100, 100, 4, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 700, 100, 100, 12, sprite, 0.1f, Color(0, 128, 128)));
    animations.emplace_back(Animation(0, 800, 100, 100, 12, sprite, 0.1f, Color(0, 128, 128)));


will probably need to figure out another way of doing this later

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
 Post Posted: October 15th, 2017, 8:06 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2782
Location: Oklahoma, United States
Man, with the last two params being the same, I'd problem make them default to those values.
Animation( int, int, int, int, int, const Sprite &, float delay = .1f, Color C = {0, 12, 128} );

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: October 15th, 2017, 1:25 pm 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3448
Location: Japan
Yeah, you may want to write a more sophisticated class for animations, what I did in the tutorial was very basic. Support for start and end sequences might be nice.

Platformers are a prime place to apply the technique of state machines as well.

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post Posted: October 15th, 2017, 4:50 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 487
Location: Idiot from northern Europe
^ Yep I'll look into that a bit. For now I just wanted to get the animations running so I could see if my sprite sheet was working.

The main idea with this project is to practice designpatterns from gameprogrammingpatterns. So stuff like state machine, observer, command etc.

Will post progress when there is any but I'm guessing progress will be slow on this one due to limited time for it

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 627 posts ]  Go to page Previous  1 ... 59, 60, 61, 62, 63  Next

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: