Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 13 Jun 2001
Online Last Active Today, 06:28 AM

#5123085 Animation code, simplify code

Posted by Madhed on 12 January 2014 - 11:43 AM

Hm, the code is really confusing. What exactly is going on here?

If you just want to find out the current animation frame to display, you could just do:


Edit: ...assuming every frame lasts for 1/50th of a second. I'm not sure if I read that correctly in the original post.

double dt; // Time since last update in seconds
double animationTime; // Time since the animation started in seconds
int numAnimationFrames; // Number of frames in animation
double timePerAnimationFrame = 1.0/50; // 50 fps
animationTime += dt; // Add passed time to animation
int currentAnimationFrame = int(animationTime / timePerAnimationFrame) % numAnimationFrames; // Get currently displayed frame, and loop

#5121226 Well into my first full game soundtrack. Any advice for advancing after this...

Posted by Madhed on 04 January 2014 - 04:44 PM

I can't give you any advice on this. Just dropping by to say I really enjoyed the music! Well done!

#5121125 Has there ever been game engines or libraries in assembly?

Posted by Madhed on 04 January 2014 - 07:56 AM

The Lucas Arts Adventures like Monkey island and Day of the tentacle used a virtual machine called scummVM. Actually I don't know if they used assembly for the engine but given the time I'm pretty sure large parts of it were written in ASM.


Also, Another world (Out of this world) was written as a virtual machine and could thus be ported to a lot of different platforms.

#5120735 float unlimited increasing rotation or use a if

Posted by Madhed on 02 January 2014 - 11:45 AM

@ Madhed : What is meaned with high level optimalisation ?


Low level: Optimizing small self contained functions like sin() cos() min() max() that are repeated 1000s of times.

High level: Finding better algorithms so you don't even have to call those things 1000s of times.


I don't know the code, so I'm just guessing.


If you find out that you spend 50% of the time in a function that is called millions of times your first idea might be to make the function faster, while it might be even better and easier to make sure the function isn't called that often in the first place.


Can you try http://www.codersnotes.com/sleepy (Very sleepy) ? It's a simple stochastic profiler that you can use to measure your program performance. It shows you were your program is spending most of its time.


If you like you can post screenshots of the results, so maybe we can discuss what's going on there.

#5120057 float unlimited increasing rotation or use a if

Posted by Madhed on 30 December 2013 - 11:10 AM

Can a i7 be faster with sin() instead of a lookuptable? , and maybe a Celeron ( which is my current game development pc with onboard graphics ) cant ?


Lookup tables are so 1990's. Think of the cache. Processors have become lightning fast since then while ram speed has not.

Also the line "i,m telling you : games are not playable with functions like sin() and cos() and sqrtf() ( i still need to get some fast sqrtf function by the way )." had me a retro-chuckling.

#5118226 Camera shake

Posted by Madhed on 19 December 2013 - 02:52 PM

shape the falloff function so it goes from 1 to 0 in 5 seconds: f(x) = 1-x/5


Then that would give you: shake(x) = sin(2*x) * (1-x/5)


That would be a linear falloff and assuming x starts at 0.


This is called easing and here are some nice examples: http://www.gizma.com/easing/

#5115402 What Language or Languages for Web and Mobile Apps

Posted by Madhed on 08 December 2013 - 11:39 AM

You basically have two options: Create native apps or create packaged web apps.


The latter is just a frameless browser window, running in fullscreen, displaying a local webpage. The framework supplies additional functionality that you usually

can't access from the web though. Camera access, File system, Microphone, Cross domain requests, etc.


Pro: Can reuse most of the code on any supported platform. Can resuse code from your website.

Contra: Is relatively slow. Uses more resources. Not all device features available.


Native app:


Pro: Can be optimized to run very fast and efficiently.

Contra: Different codebase for each operating system.


Languages used:


Native iOS: Objective-C / C / C++

Native Android: Java / C / C++

Packaged web app: Javascript / HTML / CSS


You also have the option to use a cross platform engine like Unity3D for example, where most of the code is written in C#.


If you want to deploy to iOS you ultimately have to have a Mac since the software (XCode) is only available for that. Some people have had success with a hackintosh although I don't know the legal consequences of using one to create iOS software.


For going the WebApp route I have used http://cordova.apache.org/ in the past, I think it's the most popular at the moment.

#5115230 Game State Machine with Component Based Entity Design

Posted by Madhed on 07 December 2013 - 05:07 PM

The state should not be the owner of the subsystem. That's the problem. The subsystems are services that your engine provides. The state is a client that can access these systems, that doesn't mean they cease to exist after you switch from one state to another.




The "gameplay" state holds Physics System, Graphics System, and Input System, while the "main main" state holds GUISystem and InputSystem


This is an arbitrary separation. What if you want to display a physically correct exploding character in your main menu or you want to display a GUI over your game scene?

#5115142 timeBeginPeriod under Windows 8.1 is always 15ms using GetTickCount?

Posted by Madhed on 07 December 2013 - 11:02 AM

IIRC this function used to change the timing behaviour of the whole system. Maybe they changed its behaviour in windows 8...

I guess you'd be better off using QueryPerformanceCounter and QueryPerformanceFrequency

#5113847 JavaScript local storage

Posted by Madhed on 02 December 2013 - 03:04 PM

You are confusing localstorage with WebSQL, which are two deifferent things. While localstorage is a simple, widely supported key-value storage WebSQL is outdated.







#5111432 Noob Question : What game engine is better to begin to program in C# for Desk...

Posted by Madhed on 23 November 2013 - 06:44 AM

Unity uses C# and is more of an engine. It's more 3D focused but you can do 2D with it also. I think that's probably what you are looking for.


FYI Unity just released version 4.3 with a dedicated 2D pipeline!

#5105991 8-bit or 16-bit?

Posted by Madhed on 31 October 2013 - 10:39 AM

These are both jpgs. So... 24bit?


If with 8bit vs. 16bit you mean the art style associated with the computer systems of the time (i.e NES vs. SNES) I'd say they are more 8bit.

16 bit to me would mean higher resolution and more colors.

#5105921 Quicksand now lets you create games in JS and export to iOS, Android and HTML5

Posted by Madhed on 31 October 2013 - 06:02 AM

Looks pretty interesting, although i feel this post should be moved to "Your Announcements"

#5104393 When the class name is the same as its instance...

Posted by Madhed on 25 October 2013 - 11:14 AM

Upper camel case for variables seems unusual.

I think there is always a way to express the purpose of the instance. Even if it is just defaultRenderer, currentRenderer or the like.

#5102606 Physics engine or DIY?

Posted by Madhed on 19 October 2013 - 06:22 AM

Do you mind if I briefly hijack this thread to ask what sort of collision resolution methods work well for racing games? Particularly given you need incredibly smooth movement over terrain...


I don't know about Hodgman's approach, but the most widely used and easiest to implement seems to be the raycasting model. Shoot a ray from the wheel hub downwards to find the contact point, compute forces based on the suspension spring/dampening, steering, wheel rpm, slip angle, tire model, etc. you can get as crazy as you like.