Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Feb 2008
Offline Last Active Private

#5259629 Confused at rotating an object around a transformed circle

Posted by on 29 October 2015 - 03:13 PM

I tried that previously here: http://jsfiddle.net/j1s3vopd/ but it is still slightly off. I could not work out why it was slightly off the line all the time.


EDIT sorry just saw a mistake in my draw function and now it works perfectly.

Thank you @ MarkS

#5257169 Techniques for "Smooth" camera scroll with mouse

Posted by on 13 October 2015 - 10:43 PM

Problem solved: http://jsfiddle.net/gswcnb/

Thought i'd post the link just encase it helps others smile.png

#5253248 Easing a camera offset

Posted by on 20 September 2015 - 11:43 PM



I am trying to get my camera to move with an easing movement to a position i click on my game out canvas. It currently seems to shoot off at light speed, and always in the same direction no matter where I click on my screen.

I tried to calculate the direction based on where i clicked relative to the middle of my screen. I am using JavaScript by the way, and this was my attempt:


self.easing = function(x) {
    return 0.5 + 0.5 * Math.sin((x - 0.5) * Math.PI);

self.mouseEvents = function(e,el){      
    var mousePos = mouse.relativePosition(e,el); //relative to element that was clicked {'x':int,'y':int} format
    var parent   = el;
    if(e.button == 0){ //left click
        //middle of element is our camera position for user
        var initial   = {'x':canvas.width/2,'y':canvas.height/2}, 
            delta     = {'x':mousePos.x - initial.x,  'y':mousePos.y - initial.y},
            timeStart = new Date().getTime();
            timeLength= 800;


    function update(){
            function fraction(t){   
                 canvas.offsetX -= initial.x + t * delta.x,
                 canvas.offsetY -= initial.y + t * delta.y;             
            var t = (new Date().getTime() - timeStart) / timeLength;
                if (t > 1) {
                } else {
    parent.scroll = setInterval(update, 10); 

// called from main game loop (infinite loop):

self.draw = function(){
    var x = img.x - (img.width/2) - canvas.offsetX;
    var y = img.y - (img.height/2) - canvas.offsetY;

I also made a fiddle of the code: http://jsfiddle.net/p61f5k3z/

I am curious where I have gone wrong? I am currently thinking its my math logic some where, but I can't figure out what the mistake is. 

#5000408 sfml uncompatibility with .mp3, .wav suggest audio format

Posted by on 12 November 2012 - 07:15 PM

You want a lossless compressed format unless sound quality isn't a big deal then you go for lossy compressed formats. MP3 to my knowledge is not free to use, it has a license to use in your applications, so this might be why they don't support MP3 format.

Note that lossy formats will be lower in file size where as lossless formats will be larger. For example i have a 11 minute flac audio file which is pushing 80 meg in size. How ever in mp3 format its about 11meg. (Mp3 is a lossy compression format).

More reading material here: