Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Movement Stuck With Options of Up and Left...
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jeffrey Palmer  
View profile  
 More options Jun 10 2012, 12:01 pm
Newsgroups: perl.sdl.devel
From: jeffrey.t.pal...@gmail.com (Jeffrey Palmer)
Date: Sun, 10 Jun 2012 12:01:29 -0400
Local: Sun, Jun 10 2012 12:01 pm
Subject: Re: Movement Stuck With Options of Up and Left...
Hi Jack,

The problem is that an SDL::Rect stores it's x and y coordinates as
integers.  When you subtract a small value from the coordinate the new
coordinate is truncated, which is why you are able to move in negative
directions.  When you add a small value the same thing happens, but the
truncated value is the same as the value you added to, so no movement.  To
work around this, store the coordinates in variables outside of the rect,
add and subtract using these variables, then update the SDL::Rect
coordinates.

Jeff

On Sun, Jun 10, 2012 at 7:50 AM, Jack Maney <jma...@adknowledge.com> wrote:
> Everyone,

> First of all, thanks to Tobias Leech for so quickly answering my previous
> question on alpha values.

> Now, I'm trying to understand movement.  I managed to hack together a
> simple, choppy, "movement by teleportation" app in which one can use ASDW
> to move a rectangle around in the screen.  However, inspired by the Pong
> code in the SDL manual, I'm trying to recreate this properly by using
> motion handlers.  The resulting code is at http://pastebin.com/mVHANk7T

> The strange thing about it is that movement works just fine, but only up
> and to the left (ie via A and W) not to the right or down (ie via D and S).
>  I'm at a bit of a loss as to what's going on...why would a negative
> x-velocity and positive y-velocity be fine, but not a positive x-velocity
> or a negative y-velocity?  I know that the correct velocity values are
> being set (by de-commenting the debugging print statement and running the
> code), so it's not an issue of the wrong velocity values being set...  Is
> there something obvious that I'm missing here?

> Thank you for your time,

> Jack

--
Jeffrey T. Palmer

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.