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

Username:   Password: 
 RegisterRegister   
 Help shooting in megaman program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nick48




PostPosted: Thu Apr 29, 2010 7:36 am   Post subject: Help shooting in megaman program

What is it you are trying to achieve?
I need it to shoot straight across.

What is the problem you are having?
I can't figure out how to do it.

Describe what you have tried to solve this problem
Everything


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing:


%Nick Moscioni

var picID : array 1 .. 4 of int
var sprite : int
var chars : array char of boolean
var background : int
var x1,xchange : int
var y1,ychange : int
x1:=50   
y1:=50   
xchange := Rand.Int (0,10)-5
ychange := Rand.Int (0,10)-5
var x, y : int
x := 30
y := 60
picID (1) := Pic.FileNew ("Untitled-1.gif")
picID (2) := Pic.FileNew ("Untitled-2.gif")
picID (3) := Pic.FileNew ("Untitled-3.gif")
picID (4) := Pic.FileNew ("Untitled-4.gif")
background := Pic.FileNew ("megaman2_2.jpg")
% Create the sprite
Pic.Draw (background, 0, 0, picMerge)

sprite := Sprite.New (picID (1))
Sprite.SetPosition (sprite, x, y, false)
        Sprite.Show (sprite)
 

% Move the sprite across the screen
loop
    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
        Sprite.ChangePic (sprite, picID (2))
        Sprite.Show (sprite)
        delay (10)
        y := y + 3
        Sprite.SetPosition (sprite, x, y, false)
       
    elsif chars (KEY_RIGHT_ARROW) then
        Sprite.ChangePic (sprite, picID (1))
        Sprite.Show (sprite)
        delay (10)
        x := x + 3
        Sprite.SetPosition (sprite, x, y, false)
       
    elsif chars (KEY_LEFT_ARROW) then
        Sprite.ChangePic (sprite, picID (3))
        Sprite.Show (sprite)
        delay (10)
        x := x - 3
        Sprite.SetPosition (sprite, x, y, false)
       
    elsif chars (KEY_DOWN_ARROW) then
        Sprite.ChangePic (sprite, picID (4))
        Sprite.Show (sprite)
        delay (10)
        y := y - 3
       
        Sprite.SetPosition (sprite, x, y, false)
       
            elsif chars ('a') then
           
        drawfilloval (x1, y1, 5, 5, blue)

        delay (1)
       
        if x1+xchange > maxx or x1+xchange < 2 then
            xchange:=xchange * -1
        end if       
        if y1+ychange > maxy or y1+ychange < 2 then
            ychange:=ychange * -1
        end if       
       
        x1 := x1 + xchange
        y1 := y1 + ychange

    end if

end loop

Sprite.Free (sprite)




Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
USEC_OFFICER




PostPosted: Thu Apr 29, 2010 11:43 am   Post subject: RE:Help shooting in megaman program

We need a better explaination than trying to shoot straight across. I'm not a mind reader...

Yet.
Turing_Gamer




PostPosted: Thu Apr 29, 2010 11:54 am   Post subject: RE:Help shooting in megaman program

What you need to do is have an if statement saying if bullet is onscreen, then xbullet will change or ybullet if you aim up. Else reset bullet position offscreen and don't move 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 1  [ 3 Posts ]
Jump to:   


Style:  
Search: