Jump to content
IGNORED

Variable Addition Weirdness


flux

Recommended Posts

I seem to be getting incorrect results when I'm adding two variables together. I'll call them A and B for example. If A=178 and B=296, the answer I get when I add them and store the answer in variable 'C' and print that variable to the screen is 47495680. The first three digits are the correct answer, and no matter what values I set A and B to, the first digits will always be accurate. But it seems to be appending a bunch of digits or multiplying it by some hundred odd thousand or so. There's no other code changing these variables between the time they're set and when they get printed to the screen.

 

Am I running out of memory or reaching some other kind of limitation? Everything seemed to be going well previously...

 

 

Edit: Disregard. I think I figured it out. But there's no way to delete a post here? Even if it has no replies?

Edited by flux
Link to comment
Share on other sites

It was more a case of I didn't describe the situation accurately and I'm embarrassed to admit I didn't catch it before I posted. At the time, it was so inexplicable that I had no idea what to do. Turns out, I had the wrong variable assignment statement commented out and one of the variables was indeed changing, and at a pretty rapid pace. I didn't look into it enough to investigate why it kept the correct digits at the front. It seems like it ought to have been more random than that but I was just happy to get rid of that whole thing.

 

However, and maybe this isn't the best spot for this and I should start a new thread. There does seem to be some other unrelated weirdness I can't seem to get straightened out. I have a couple of variables for my sprite's x and y coordinates, and sometimes I will print those values to the screen when such information is useful. The problem is that half the time, the numbers seem to jump all over the place. My x coordinate will jump from 100 something to 600 (well outside of the area for the resolution I'm at) and then maybe back down to something else and then at some point return to something expected and normal. The weird bit is, as near as I can tell, my sprite isn't jumping around accordingly. It just keeps moving smoothly and steadily around the screen. I haven't worried about it too much yet since it doesn't seem to actually break anything. I'm sure I'm doing something wrong and I'll figure it out eventually, but does that sound familiar to anyone?

 

On a related note, is there a way to look up and return the current properties of an object such as its coordinates or flip status or scale value or is the only way to do it is manually track that stuff with variables?

  • Like 1
Link to comment
Share on other sites

Flux it sounds like you have fallen foul of solving bugs the way I have done many times :)

 

You hit a bug, it makes no sense, you try to figure it out, get no where, so you grab a nearby colleague (in this case the forum) and explain the problem to them, except that as you are explaining the solution presents itself and you realise what you did wrong, quite often they don't even get the full detail of the issue. :) (or there about)

 

I recommend you get yourself some teddy bears, or rubber ducks, (or some other inanimate object), when you hit a problem like this, try explaining it to one of the ducks/bears/etc.. whilst they'll not say anything, can cause you to find something you had previously overlooked... can be good to have a few in case the 1st couple don't yield results..

 

Then there is always the forums when this doesn't work (except GGN/Zero will occasionally quack :D )

  • Like 5
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...