Var Equal two values added togheter in loop...?

BlitzMax Forums/BlitzMax Beginners Area/Var Equal two values added togheter in loop...?

Apollonius(Posted 2007) [#1]
Stupid question,

I got a loop, let's say I got two values x1=50, x2=50 and I wana add them togheter to equal 100 or whatever they make togheter whenever they change... How should I do that..

To me the logic thing to do is
(remember this is a loop)

local total:int = x1 + x2
local container:int=total:int

so container should always be 100 until either x1 or x2 changes... bvasicly I wana contain the addition of x1 + x2 into a variable and it needs to be in the loop because x1 and x2 can change.

I tried it but it seems to always keep adding +100 to the container..? I somewat confused.


H&K(Posted 2007) [#2]
well youve just made a mistake. Why not post the code?


Apollonius(Posted 2007) [#3]
The actual code is freaken big

Basicly I've got Type Window and a Type Button and I'm trying to make the Type Button Follow the Type Window so adding the handler Xpos to the Xpos of the Button should always make it follow the window since the window type is dragable...

This is the button Object which is bigger then this: Draw and Update
removed


Basicly in the LOOP I update the Window like test.Update() (winodw is called test) which updates the Button through the Update() code above..

Goal= to make the Button Follow the Window even when the Xpos and Ypos changes for the Window(but the Xpos for the button wont ever change)


H&K(Posted 2007) [#4]
This code is from the other problem you had. And bares no relation to the question you asked


Apollonius(Posted 2007) [#5]
Well yeah it does H&K, basicly I'm adding two values togheter from variables

Local test12:Int = Xpos + Handler.Xpos
Xpos = test12

In the loop... but when I run it my Buttons just fly off the screen because they keep going right->>

and Since test2 equals the two variables togheter
and then Xpos equals test2 it... equals it shouldn't add anything...

That's how I see it..?

edited
although i I think about it that equals:
Xpos=Xpos+Handler.Xpos
Xpos:+Handler.Xpos
... hmmm


Apollonius(Posted 2007) [#6]
FIXED I just modified the Drawing Instead and it fixed it all.