Darren New wrote:
> The problem comes from you reading 2-byte values into 4-byte integers.
> You can't expect that to work properly.
>
> You need to either make it
> val = buf[0] + 256 * buf[1]
> or
> val = buf[1] + 256 * buf[0]
I made the changes you suggested and it works perfectly. There is no
need to set "val" to an initial value now that I am writing to the
correct data type. I can feel better about my code.
Now I can start working on a simple character class to test field
scrolling and collision detection. I'm really digging OOP at this point.
My global variables are few and I can load several fields at once. I
might even have a chance at finishing a game.
Your input has been very helpful! I don't know why I didn't think to
print values to the console for debugging before, it's so useful :) Now
I will consider my data types and memory usage more carefully. Thanks
Darren!
> The folks with conficker installed would almost certainly have preferred
> that IE crash gracefully. :-)
People should know by now not to use IE =P
Sam
P.S. I'm jealous. You live near some of the best mineral hunting grounds
in the U.S. ;)
Post a reply to this message
|