Frame rate independent game loop

Game development specific discussions.
dafhi
Posts: 1172
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Postby dafhi » Oct 30, 2017 17:28

where i'd like to go next is cloud data. it will ease my transition to solid-looking objects. talking to myself but it should give you ideas as well
paul doe
Posts: 727
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Postby paul doe » Oct 30, 2017 19:57

dafhi wrote:where i'd like to go next is cloud data. it will ease my transition to solid-looking objects. talking to myself but it should give you ideas as well

What is the meaning of 'solid' in this context? Are you referring to the S.O.L.I.D. acronym, or the 'solid' adjective? =D
And which type of clouding are you looking for? Do you mean networking code? Lots of questions XD
dafhi
Posts: 1172
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Postby dafhi » Oct 30, 2017 20:23

point cloud as a starting point

in the past:
1. transform -> projection array
2. zsort

currently thinking about more than 1 object which will mean zsorting a more-or-less global array
paul doe
Posts: 727
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Postby paul doe » Oct 30, 2017 20:54

dafhi wrote:point cloud as a starting point

in the past:
1. transform -> projection array
2. zsort

currently thinking about more than 1 object which will mean zsorting a more-or-less global array

OOOOOh that! I thought you were referring to OOP =D
If you want to do z-sorting, z-buffer or c-buffer all the way. If you z-sort the objects (whether by using the centroid or whatever), you end up with z-fighting all over the place. Unless you'll do lots of transparency, there's no point in sorting the objects. A good idea that I implemented (has to be there somewhere...) is using a binary heap (instead of a simple array list) when you compute the potential visibility set. You may want to try it ;)
I'll see if I can refactor the paperplane demo to use a z-buffer. Then you can use that as a base for point clouding all the way (I have something on that also, but where... XD)
dafhi
Posts: 1172
Joined: Jun 04, 2005 9:51

Re: Frame rate independent game loop

Postby dafhi » Oct 30, 2017 23:47

yes the global array will be point cloud data.

[edit:]
it's been an interesting week - transitioning to a vegan lifestyle in a rather short time
Last edited by dafhi on Oct 31, 2017 17:37, edited 1 time in total.
BasicCoder2
Posts: 3245
Joined: Jan 01, 2009 7:03

Re: Frame rate independent game loop

Postby BasicCoder2 » Oct 31, 2017 6:21

paul doe wrote: I was thinking in more 'mundane' 2D physics, like Angry Birds or LBP.

My attempt at angry bird "physics" :)
viewtopic.php?f=15&t=21667&hilit=angry+birds
You code example looks great. Couldn't figure out how it worked of course or even imagine how to duplicate it. So many files to download!!
.
paul doe
Posts: 727
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Postby paul doe » Oct 31, 2017 6:47

dafhi wrote:yes the global array will be point cloud data. just talking to myself :-)

there are several factors for my slowness:
1. my mental horsepower isn't large
2. i have PTSD which greatly affects #1
3. spiritual issues on top of #2 (far and away the most confounding aspect of my life)
4. big life changes - transitioning to a vegan lifestyle in a rather short time
5. potentially found 'that special someone'

several points tie with each other. needless to say i've been hugely distracted. maybe not the right word considering the implications of point #5

You have too much coupling in your life. Inherit from interfaces, instead of extending the implementation =D
Well, if you need me, I'll be right here. I will just leave you with you deranged ramblings for now XD
paul doe
Posts: 727
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Postby paul doe » Oct 31, 2017 6:54

BasicCoder2 wrote:
paul doe wrote: I was thinking in more 'mundane' 2D physics, like Angry Birds or LBP.

My attempt at angry bird "physics" :)
viewtopic.php?f=15&t=21667&hilit=angry+birds

Haha pretty hilarious. I totally missed that one, will take a good look at it later =D

BasicCoder2 wrote:You code example looks great. Couldn't figure out how it worked of course or even imagine how to duplicate it. So many files to download!!.

The comments in the code didn't help you? I carefully commented every piece worthy of some consideration, even described the algorithm in detail. Do you think there are many files? You haven't seen anything yet =D
BasicCoder2
Posts: 3245
Joined: Jan 01, 2009 7:03

Re: Frame rate independent game loop

Postby BasicCoder2 » Oct 31, 2017 7:28

paul doe wrote:Haha pretty hilarious. I totally missed that one, will take a good look at it later =D

Looking at it again I see the collision routine was more complicated than it needed to be for that usage.

Code: Select all

function imagesCollide2(s1 as SPRITE,s2 as SPRITE) as boolean
    return (s1.y+s1.h) > (s2.y) and (s1.y) < (s2.y+s2.h) and (s1.x) < (s2.x+s2.w) and (s1.x + s1.w) > (s2.x)
end function


Do you think there are many files? You haven't seen anything yet =D


Well I am a retro programmer from another time and if it doesn't fit in one file ...
.
BasicCoder2
Posts: 3245
Joined: Jan 01, 2009 7:03

Re: Frame rate independent game loop

Postby BasicCoder2 » Oct 31, 2017 17:56

paul doe wrote:The comments in the code didn't help you? I carefully commented every piece worthy of some consideration, even described the algorithm in detail.


I see OOP as a high level abstract language far removed from the simple languages of old although I know oop has been around for a long time even given some support in the old TASM Assembler but it just doesn't appeal to me.

As I wrote in the thread about making FreeBasic appealing,

My gut feeling is in the future FreeBasic will only be used by advanced users who like the BASIC syntax and old qbasic programmers. That is the make up I see on the forum.

There are two groups, the advanced programmer such as yourself and a few remaining retro programmers like myself and I think the future is for the advanced programmer.

I decided to look at your code and the first thing I saw was property. No idea what that meant and checked the help and did a google. Now I am sure you could explain it all but honestly I tried a long time ago to get into OOP without success. I found OOP long winded and I was unable to visualize what was going on. I can still remember the example given in a teach yourself C++ book called budget.c and budget.cpp where I fully understood the first version but saw no point in the complicated second version which did exactly the same thing.

Now I have used Java at a beginners level and I have used objects in C++ but I don't really write them. I know how to instantiate an object with the new statement and call its methods with the dot operator but that is about it. I liked that strings and arrays were objects with lots of methods so I do appreciate the value in oop as objects are easy to use.

I haven't really been doing much programming recently as I can't find a project to get excited about. I just dabble now and then with simple programs but don't have the time or motivation I had in my twenties to learn new things which require hours of practice. Maybe I should change my forum name to Dinosaur2 :) With all the advanced oop code now on the forum I see myself as redundant as a contributor.
.
Imortis
Posts: 1568
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Frame rate independent game loop

Postby Imortis » Oct 31, 2017 20:20

BasicCoder2 wrote:...I can still remember the example given in a teach yourself C++ book called budget.c and budget.cpp where I fully understood the first version but saw no point in the complicated second version which did exactly the same thing.


Sadly, most simple OOP examples are pretty useless and overly complicated. This is because OOP's complexity savings only come on larger objects. With small objects, all you get it the convenience that you spoke of with java's objects.

For instance, Property are a great way of handling access control. You make the actual member of the object private (only accessible from the object itself) or protected (only accessible from the object itself or from derived objects). Then you can make the property to give other classes access to the member. This allows you to monitor and control what changes are made to the member.

For small things, what is the point? That makes it really complicated for no good reason.

Where OOP really shines though, is when making code to be used by others. You can make an object, that has all the things it needs contained in itself. Then you can pass the object to someone else, and give them the interface to that object (properties, subs, functions, constructors, etc). They don't need to know HOW it works, just how to interact with it. Then if you find a bug in your object, you can change the interior code with out having to change any of the interface bits. Their code should not need to be changed, unless you add new features. Old features continue to "just work".

Many times, OOP is seen as this savior for programmers. It is like any other tool in the tool box. It is good for certain things and not so much for others. I have not looked over the code that was being talked about here, so I will make no judgement on whether it is a good use of OOP or not.

If you are up for it, I would love to take a crack at making some OOP tutorials for you. If you have no interest, no hard feelings. I just hate to see someone with talent feel like they are being left behind.
paul doe
Posts: 727
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Postby paul doe » Nov 01, 2017 2:17

Imortis wrote:Many times, OOP is seen as this savior for programmers. It is like any other tool in the tool box. It is good for certain things and not so much for others. I have not looked over the code that was being talked about here, so I will make no judgement on whether it is a good use of OOP or not.

Hi, Imortis.

Why don't you look, then? =D I just finished refactoring it a little, to be able to implement something that I promised to show to h4tt3n more comfortably. Your comments would be greatly appreciated.

BasicCoder2 wrote:
paul doe wrote:The comments in the code didn't help you? I carefully commented every piece worthy of some consideration, even described the algorithm in detail.


I see OOP as a high level abstract language far removed from the simple languages of old although I know oop has been around for a long time even given some support in the old TASM Assembler but it just doesn't appeal to me.

That's OK. As Imortis says, they're just different paradigms, tailored to suit different needs.
BasicCoder2 wrote:My gut feeling is in the future FreeBasic will only be used by advanced users who like the BASIC syntax and old qbasic programmers. That is the make up I see on the forum.

There are two groups, the advanced programmer such as yourself and a few remaining retro programmers like myself and I think the future is for the advanced programmer.

I beg to differ. See http://www.yegor256.com/2016/08/15/what-is-wrong-object-oriented-programming.html to see some authoritative opinions on the matter. However, I can see the appeal of OOP for the human behind the programmer. If you look at my code, you'll see that it is written to be easy to read and understand what I'm doing. Of course, if you're not familiar or know little about OOP it will tell you nothing, but for another person who does, it's really easy to read and figure out what is happening.
Knowing OOP does not make you an 'advanced programmer'. Your ability to solve problems does. I think you know what I'm talking about XD. It just so happens that I used OOP to solve a problem (the implementation of a game loop), but you can pretty much do the same thing with procedural programming.
BasicCoder2 wrote:Now I have used Java at a beginners level and I have used objects in C++ but I don't really write them. I know how to instantiate an object with the new statement and call its methods with the dot operator but that is about it. I liked that strings and arrays were objects with lots of methods so I do appreciate the value in oop as objects are easy to use.

I haven't really been doing much programming recently as I can't find a project to get excited about. I just dabble now and then with simple programs but don't have the time or motivation I had in my twenties to learn new things which require hours of practice. Maybe I should change my forum name to Dinosaur2 :) With all the advanced oop code now on the forum I see myself as redundant as a contributor.

I know what it is to not having time or motivation to spare, indeed. But this isn't necessarily so, you know. Some people would be able to use my code, some not. Such is life. It does not make it useless, as writing (solid)procedural code doesn't make you redundant. OOP isn't particularly hard to learn. The interactions between the different components, and understanding what to use, when and how is the difficult part. That's why I pointed to you the article describing some commonly used patterns, what is coloquially known as the 'GoF Design Patterns' ('GoF' meaning 'Gang Of Four', see what Google has to say about this =D ) and that (among other things) is why I think that a centralized Tutorial/Demo section would be useful.
Nonetheless, don't take me too seriously, please. I'm just a paul doe, you know. Sorry if I sounded a little harsh yesterday =D
Imortis
Posts: 1568
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Frame rate independent game loop

Postby Imortis » Nov 01, 2017 16:04

paul doe wrote:Hi, Imortis.

Why don't you look, then? =D ...


This looks well done. The complexity of the code is nicely hidden in the objects without becoming cumbersome in it's own way. 5/5 stars!

On a note purely of personal preference: I don't care for using defines to replace one keyword for another (type/class/interface, extends/inherits), especially when I am trying to write code for general use. It can get confusing for people trying to understand the code. But that is just a preference. For someone who understands OOP concepts, your defines make perfect sense.
fxm
Posts: 8301
Joined: Apr 22, 2009 12:46
Location: Paris (suburb), FRANCE

Re: Frame rate independent game loop

Postby fxm » Nov 01, 2017 17:44

Imortis wrote:On a note purely of personal preference: I don't care for using defines to replace one keyword for another (type/class/interface, extends/inherits), especially when I am trying to write code for general use. It can get confusing for people trying to understand the code. But that is just a preference. For someone who understands OOP concepts, your defines make perfect sense.

That reminds me of an old discussion:
See viewtopic.php?p=154836#p154836 and the posts before and after!
paul doe
Posts: 727
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Frame rate independent game loop

Postby paul doe » Nov 01, 2017 23:36

Imortis wrote:This looks well done. The complexity of the code is nicely hidden in the objects without becoming cumbersome in it's own way. 5/5 stars!

Thanks. Very kind of you to actually take the trouble to read the code =D
Of course, there are some classes that are very crappy (the metaball class being the worst offender), but for this simple demo it suffices XD
fxm wrote:
Imortis wrote:On a note purely of personal preference: I don't care for using defines to replace one keyword for another (type/class/interface, extends/inherits), especially when I am trying to write code for general use. It can get confusing for people trying to understand the code. But that is just a preference. For someone who understands OOP concepts, your defines make perfect sense.

That reminds me of an old discussion:
See viewtopic.php?p=154836#p154836 and the posts before and after!

Yeah, I've seen that discussion. In my code, I use 'class' to denote an object, and 'type' to denote data. Also, I use 'inherits' to distinguish between interface inheritance and implementation inheritance, for which I use 'extends'. For me it's vitally important that this is understood by the reader of the code (this is also stated in the code comments). Well pointed out, thanks!

Return to “Game Dev”

Who is online

Users browsing this forum: No registered users and 0 guests