Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Aug 2012
Offline Last Active Apr 27 2016 05:43 AM

#5077353 Poll: Does Gladwell's rule apply to game programming?

Posted by on 13 July 2013 - 08:58 AM

Could a game programmer ever achieve mastery? I guess that even if you work like 5 years in a domain (like the physics engine programmers for a modern FPS), how can you say that you are an expert in Game programming,when, for example you can't do the graphics part, or the structural organisation part? For me, everyone has room for improvement.


Let me give you one of Bjarne Stroustrup's quotes: "People who think they know everything really annoy those of us who know we don't". For me, the quote suggests that he acknowledges the fact that there is always room for improvement.


Meh, my opinion is pretty fixed, and i would never say that I am an expert even if at 60 years old i would have invented some awesome algorithm that produces pizza from my own programming language code. Especially if a teen comes to me with his own language that would give me soda with a while(1) loop. smile.png 

#5077205 Sprite and Animation

Posted by on 12 July 2013 - 03:24 PM

I don't get what you are asking for exactly, but I am asuming that you need to animate a Sprite.


From what I understand from your post, you seem to be the kind of programmer that has found OOP and thinks it is the best and most elegant solution for everything.


You don't need all those classes to animate a sprite. You just need an array that holds all the animation frames, and you loop over it once per main loop tick, changing the sprite's image with the one that the array index reaches. At the end of the animation just have an image that shows the sprite being idle.


for example, have only a Sprite class like this (pseudocode - also encompasses an animation function that goes over the frames in an array once per loop tick):

class Sprite:
    constructor::set(x,y,image,moving,frames,currentFrame,extraTime) // give it some attributes 
      x = 100
      y = 100
      image = image1
      moving = False //this is a boolean that changes state when a movement key is pressed
      frames = [image1,image2,image3,image4] // array of animation frames, taken from a spritesheet
      currentFrame = 0
      extraTime = 0
    function AnimateSprite(int secondsPast)
       if moving == true
          extraTime += secondsPast
          timeBetweenFrames = 1.0/30.0
          while (extraTime > timeBetweenFrames)
             extraTime -= timeBetweenFrames
             if currentFrame > maxNumberOfFrames:
                currentFrame = 0
           image = frames[currentFrame]
           image = image1


#4971165 2d overhead tiling "engine"

Posted by on 19 August 2012 - 11:57 AM

Thank you for the great explanation!
I've applied an extremely similar principle but I complicated myself by using a Map class instead of just an array.
The layer concept was a bit cloudy in my head but now you cleared it up.
Thanks again!