Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Running something in backround?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bc123




PostPosted: Sat Jan 21, 2012 11:40 pm   Post subject: Running something in backround?

What is it you are trying to achieve?
I want a loop to be running in backround. Example : A loop is animating a missle coming to a character, i want the user to be able to move the character, but still have that missle moving smoothly

What is the problem you are having?
Ny problem at the moment is im unsure how to do it, i was told by a friend to use procedures, but have never worked with it, and i so far have a moving character (a moving square) but still unsure how to add in the missle

Turing:


var x1 : int := 300 % used for coords of character|
var y1 : int := 10  %                             |
var x2 : int := 330 %                             |
var y2 : int := 40  %                             |
%_________________________________________________|
var x3 : int := 700 % used for coords of missle  |
var y3 : int := 10  %                            |
var x4 : int := 670 %                            |
var y4 : int := 40  %                            |
%________________________________________________|
var col : int := 52 % color of character
var pressed : array char of boolean

Draw.FillBox (x1, y1, x2, y2, col)

loop

    Input.KeyDown (pressed)

    if pressed (KEY_UP_ARROW) then

        y1 := y1 + 10
        y2 := y2 + 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 + 10
        y2 := y2 + 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 + 10
        y2 := y2 + 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 + 10
        y2 := y2 + 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 - 10
        y2 := y2 - 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 - 10
        y2 := y2 - 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 - 10
        y2 := y2 - 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 - 10
        y2 := y2 - 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 - 10
        y2 := y2 - 10
        delay (50)
        View.Update
        cls

        Draw.FillBox (x1, y1, x2, y2, col)

    end if

    if pressed (KEY_LEFT_ARROW) then

        x1 := x1 - 10
        x2 := x2 - 10
        delay (50)
        View.Update
        cls
        Draw.FillBox (x1, y1, x2, y2, col)

    end if

    if pressed (KEY_RIGHT_ARROW) then

        x1 := x1 + 10
        x2 := x2 + 10
        delay (50)
        View.Update
        cls
        Draw.FillBox (x1, y1, x2, y2, col)

    end if
end loop




Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
bc123




PostPosted: Sat Jan 21, 2012 11:45 pm   Post subject: RE:Running something in backround?

also, forgot to mention i forgot how to make a limit on how far the x1 and x2 can move to :s any ideas?
Alex C.




PostPosted: Sat Jan 21, 2012 11:56 pm   Post subject: Re: Running something in backround?

yeah, what version of turing Rolling Eyes
Alex C.




PostPosted: Sat Jan 21, 2012 11:57 pm   Post subject: RE:Running something in backround?

oh and second, do you have any code for your missile? (stronger straight forward attack or homing missile)
bc123




PostPosted: Sat Jan 21, 2012 11:59 pm   Post subject: RE:Running something in backround?

4.1.1

and no, i only have variables set for the missle
and another example of what i want, im working on this other game, and ill need this to have a backround constantly scrolling, then there will be a character that is running in one spot.
thnx
EDIT :
oh and i am going for a side attack, either from left or right
Alex C.




PostPosted: Sun Jan 22, 2012 12:04 am   Post subject: RE:Running something in backround?

make your missile coordinate try to be as close to the the characters coordinates...

example

charx>missilex
missilex-5

etc
Alex C.




PostPosted: Sun Jan 22, 2012 12:05 am   Post subject: RE:Running something in backround?

for limiting x and y...

if char x > maxboundaryx then
char x -= amount character moved right....

etc Very Happy
bc123




PostPosted: Sun Jan 22, 2012 12:06 am   Post subject: RE:Running something in backround?

im confused :s why do charx > misslex? also i made this little example, of how i would animate a missle

Turing:

var x3 : int := 700
var y3 : int := 10 
var x4 : int := 670
var y4 : int := 40 
loop
Draw.FillBox (x3, y3, x4, y4, black)

x3 := x3 - 10
x4 := x4 - 10
delay (50)
View.Update
cls
Draw.FillBox (x3, y3, x4, y4, black)
end loop
Sponsor
Sponsor
Sponsor
sponsor
Alex C.




PostPosted: Sun Jan 22, 2012 12:09 am   Post subject: RE:Running something in backround?

the greater the x value the farther right you are...
so if you want the missile to follow you and you are farther right, you add to the missiles x value to make it go FARTHER RIGHT Very Happy

simple math... ROFL
bc123




PostPosted: Sun Jan 22, 2012 12:10 am   Post subject: RE:Running something in backround?

oh, i just figured out limits my own way :s i bassicaly did
if x1 > 11 then
x1 := x1 + 10
end if
if x2 > 31 then
x2 := x2 + 10
end if

Very Happy and the box is 30x30 (i think :s) but it does work :s jus a little more pointless lines of code
Alex C.




PostPosted: Sun Jan 22, 2012 12:12 am   Post subject: RE:Running something in backround?

by the way your jumping makes you go farther into the ground... Confused
bc123




PostPosted: Sun Jan 22, 2012 12:12 am   Post subject: RE:Running something in backround?

well my idea is no matter what, the missle would scroll across the screen, and your character would jump over it, and the missle would continue on, but if i had a loop with an animation of a missle scrolling with its own delays, if i press the arrow keys and delay the characters movement, then wouldnt it affect the speed of the missle??
bc123




PostPosted: Sun Jan 22, 2012 12:15 am   Post subject: RE:Running something in backround?

yes, i realized that when i ran it, just remove one of these chunks

Turing:
        Draw.FillBox (x1, y1, x2, y2, col)
        y1 := y1 - 10
        y2 := y2 - 10
        delay (50)
        View.Update
        cls
[/syntax]
Alex C.




PostPosted: Sun Jan 22, 2012 12:16 am   Post subject: RE:Running something in backround?

no...

loop
box moves...
delay
missile moves...
delay
endloop

how many times is the character delayed in comparision to the missile? Smile
bc123




PostPosted: Sun Jan 22, 2012 12:18 am   Post subject: RE:Running something in backround?

well if u jump, i have like 6 delays, wont that affect the missle? like it will take longer to get through the loop to add distance to the missle and output it
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 24 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: