• What are you working on? V2
    2,001 replies, posted
[QUOTE=r4nk_;16669941]youre gonna want to make your animation/movement etc all based on time rather than frame rate[/QUOTE] I tried reading up on frame independent movement but I ended up confusing myself more...Specifically about how I can apply this to my code, since I couldn't find any SFML examples (trying to port over something from another non-SFML example ended up breaking more stuff) [url]http://pastebin.com/m4bc33e07[/url] Any tips/examples using my code will be greatly appreciated.
There's 2 ways. Record the time when you start your frame. Then compare that time to the time the previous frame started and get the difference. So now you have how long the previous frame took. Now multiply all your movements by that amount. So: x = x + 1 becomes x = x + 1 * FrameTime So if you have 10 frames a second it will move the same speed as 60 frames a second. The second is to have a set timestep. This is probably the more professional way to go about it.
[QUOTE=garry;16672056]There's 2 ways...[/QUOTE] Ah that cleared it up. It seems I was doing that math but in the wrong place. SFML has a GetFrameTime function that returns the time since the last frame and I was multiplying that by the wrong variable. I was previously using very small values for speed such as 1-5 and the ball I made would go faster with higher frame rates. Now it goes really slow with those small values BUT it moves at the same speed/smoothness regardless of the framerate, so that's working now. Thanks!
Frame-independent movement was actually covered in the SFML tutorials. :p
[QUOTE=zyxxyz;16673414]Frame-independent movement was actually covered in the SFML tutorials. :p[/QUOTE] Yeah that is true, I read a few times over that tutorial but always ended up getting it wrong since I was trying to accomplish motion with acceleration/deceleration. I just assumed it wasn't what I was looking for, especially after seeing how complex frame independent movement might be ([url]http://www.gamedev.net/reference/articles/article1382.asp[/url]). I love SFML for making it so much simpler :P
[QUOTE=Sasupoika;16671469]Cleared stage to test bullet-function. -Removed because it takes time to load- You are hating the final attack-candinate already? ( Those bullets actually go extremely fast, GIF just doesn't show it. ) Edit: I think this is better; Blue bullets turn left, red bullets turn right ( or was it the other way around? )[/QUOTE] Touhou? Snap.
[QUOTE=adzicents;16688625]Touhou? Snap.[/QUOTE] [url=http://www.youtube.com/watch?v=jKWXubTH5jA&feature=related]N[/url][url=http://www.youtube.com/watch?v=5ztCxpBmXuA]o[/url][url=http://www.youtube.com/watch?v=FtFkpldJSpY]p[/url][url=http://www.youtube.com/watch?v=N6LF130hE-8&feature=related]e[/url] It's more like Cave's shmups. I just can't stop loving them.
Hard to see, but I got reflections/mirror rendering properly. [img]http://img228.imageshack.us/img228/4109/14aug2009002.jpg[/img] There's depth issues because there's no stencils or rendering to textures yet. The grunt work is done though!
Working on a post processing system (for a game project @ uni), finish my VBO class and 1/2 done my shader class. Time to sleep I guess.
Eh, working with a new school laptop - it's hell when you don't have the screen estate. How do people manage 1024x768 on small notebook screens? After flipping through a bookstore's copy of Head Start on Design Patterns or something, I decided to (rather shortsightedly) implement a thingee that sends notifications whenever it passes and event and every time it gets drawn. I'm actually surprised the GMA 950 can take it, although I'm suspecting the CPU's doing all the grunt work. [media]http://www.cubeupload.com/files/f9f200untitled.png[/media]
[QUOTE=HubmaN;16693405]Eh, working with a new school laptop - it's hell when you don't have the screen estate. How do people manage 1024x768 on small notebook screens? After flipping through a bookstore's copy of Head Start on Design Patterns or something, I decided to (rather shortsightedly) implement a thingee that sends notifications whenever it passes and event and every time it gets drawn. I'm actually surprised the GMA 950 can take it, although I'm suspecting the CPU's doing all the grunt work. [media]http://www.cubeupload.com/files/f9f200untitled.png[/media][/QUOTE] [img]http://imgkk.com/i/1Hgktg.png[/img] :bang:
Yay, obvious memory leaks, now in loops!
[QUOTE=HubmaN;16693405]Eh, working with a new school laptop - it's hell when you don't have the screen estate. How do people manage 1024x768 on small notebook screens? After flipping through a bookstore's copy of Head Start on Design Patterns or something, I decided to (rather shortsightedly) implement a thingee that sends notifications whenever it passes and event and every time it gets drawn. I'm actually surprised the GMA 950 can take it, although I'm suspecting the CPU's doing all the grunt work.[/QUOTE] gma 950 runs source
[QUOTE=nullsquared;16694351] [IMAGE OF CODE] :bang:[/QUOTE] I've never done this in my code (not sure why I would anyway), but why is that piece of code so tragically bad? *waits for obligatory dumb ratings*
[QUOTE=Sporbie;16694951]I've never done this in my code (not sure why I would anyway), but why is that peace of code so tragically bad? *waits for obligatory dumb ratings*[/QUOTE] The "new" operator allocates an object on the heap and returns a pointer to it, but since the pointer only exists as a temporary variable, he never gets the chance to delete it. His RegisterObserver function then gets a copy of this object, while the object on the heap is lost forever (memory leak). He's leaking sizeof(GenericObserver) bytes of memory per iteration in that loop.
This is probably the first real project I'm working on, I've been learning C++ for a years along with SDL and Qt. My Zelda game: [img]http://i26.tinypic.com/ao0u2h.png[/img]
[QUOTE=jA_cOp;16695036] His RegisterObserver function then gets a copy of this object (or a reference to the copy), while the object on the heap is lost forever (memory leak).[/QUOTE] No, if RegisterObserver takes a reference, then you'll get a reference to the heap-allocated object, and then you can do delete &ref. However, that reeks of horrible design, and if you do indeed delete the object, you should just use pointers in the first place.
[QUOTE=jA_cOp;16695036]The "new" operator allocates an object on the heap and returns a pointer to it, but since the pointer only exists as a temporary variable, he never gets the chance to delete it. His RegisterObserver function then gets a copy of this object (or a reference to the copy), while the object on the heap is lost forever (memory leak). He's leaking sizeof(GenericObserver) bytes of memory per iteration in that loop.[/QUOTE] Well that's epically retarded. Couldn't he just make the RegisterObserver function accept pointers to GenericObserver, or am I missing something painfully obvious again?
[QUOTE=Sporbie;16695814]Couldn't he just make the RegisterObserver function accept pointers to GenericObserver?[/QUOTE] Exactly my point.
[QUOTE=Sporbie;16695814]Couldn't he just make the RegisterObserver function accept pointers to GenericObserver, or am I missing something painfully obvious again?[/QUOTE] If he wanted a copy, he could just allocate the GenericObserver on the stack instead. Otherwise, yeah he should be using a pointer. [QUOTE=nullsquared;16695763]No, if RegisterObserver takes a reference, then you'll get a reference to the heap-allocated object, and then you can do delete &ref.[/QUOTE] I didn't know that. Is that a special case for references, then?
[IMG]http://i429.photobucket.com/albums/qq12/the1trueryandaniels/wordwrap.png[/IMG] How do you like the font?
[QUOTE=jA_cOp;16695917]I didn't know that. Is that a special case for references, then?[/QUOTE] No, but if you have a reference then you can use addressof on it to get its address. If you pass by value, you can't use addressof then addressof again (it would make no sense - imagine if more than one pointer pointed to the object; Which pointer should it return?) References are passed as-is in C++, unlike C# where the default behavior is to pass references by value. EDIT: Explaining this correctly is a mind fuck when you're not a native speaker. I rewrote this like 6 times.
[QUOTE=gparent;16696620]No, it's just that if you get a reference, then you can use addressof on the reference, and then work a delete from there (remember that you use delete on a pointer and not the pointed memory). References are passed as-is in C++, unlike C# where the default behavior is to pass references by value.[/QUOTE] I was referring to using the dereference operator on a pointer when initializing a reference. And Wikipedia already answered my question. [quote]There is a simple conversion between pointers and references: the address-of operator (&) will yield a pointer referring to the same object when applied to a reference, and a reference which is initialized from the dereference (*) of a pointer value will refer to the same object as that pointer, where this is possible without invoking undefined behavior.[/quote]
[img]http://cubeupload.com/files/bc0400swordfaightpic.png[/img] Proving harder than I thought to fuse mouse-controlled swordfighting and hack'n'slash platforming together.
[QUOTE=Namelezz!;16697476][img]http://cubeupload.com/files/bc0400swordfaightpic.png[/img] Proving harder than I thought to fuse mouse-controlled swordfighting and hack'n'slash platforming together.[/QUOTE] Reminds me of the epically awesome Bloody Zombies game.
[QUOTE=ryandaniels;16696578][IMG]http://i429.photobucket.com/albums/qq12/the1trueryandaniels/wordwrap.png[/IMG] How do you like the font?[/QUOTE] Erm, it's called [i]word[/i]-wrapping because it breaks between words.
Letter wrapping :v:
[IMG]http://i429.photobucket.com/albums/qq12/the1trueryandaniels/wordwrap_oops.png[/IMG] oops [editline]02:40PM[/editline] [QUOTE=Ortzinator;16697777]Erm, it's called [i]word[/i]-wrapping because it breaks between words.[/QUOTE] Yeah, still got to get the words to wrap, but now that I've got the basic code it won't be too hard to implement.
Looks like you forgot to set x to 0 haha.
[QUOTE=nos217;16698776]Looks like you forgot to set x to 0 haha.[/QUOTE] yeah :D. I just finished a edit to make it the text editable, however it seems the text isn't wrapping once I start adding stuff to the middle: [IMG]http://i429.photobucket.com/albums/qq12/the1trueryandaniels/wordwrap_edit.png[/IMG]
Sorry, you need to Log In to post a reply to this thread.