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

Username:   Password: 
 RegisterRegister   
 Aiming problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
upthescale




PostPosted: Tue Jun 06, 2006 7:55 pm   Post subject: Aiming problem

I have been trying this for a while. I would like a bulelt to shoot, where ever the Thick Line points to. So it it is point up, I would like the bullet yo go up. If it it gonig diagonally, i would like teh bullet to go diagonally

code:

setscreen ("offscreenonly;nobuttonbar;position:122;122;graphics:600;500")
var Ballx, Bally : int
var Move : array char of boolean
var Aimx, Aimy, Fire : int
var Bulletx, Bullety : int
var Shoot : boolean := false
Ballx := maxx div 2
Bally := maxy div 2
Bulletx := Ballx
Bullety := Bally
loop
    Input.KeyDown (Move)
    Mouse.Where (Aimx, Aimy, Fire)
    colorback (green)
    cls

    Draw.FillOval (Ballx, Bally, 16, 16, 7)
    Draw.ThickLine (Ballx, Bally, Aimx, Aimy, 5, 7)


    if Fire = 1 then
        Shoot := true
    end if

    if Shoot = true then
        Draw.Oval (Bulletx, Bullety, 6, 6, 0)
        Bulletx += Aimx div 50
        Bullety += Aimy div 50
    end if
    %   Draw.Oval (Bulletx, Bullety, 6, 6, 0)


    if Bulletx > maxx or Bullety > maxy or Bulletx < 0 or Bullety < 0 then
        if Fire = 1 then
            Bulletx := Ballx
            Bullety := Bally
        end if
    end if
    delay (12)
    View.Update
end loop


Any help plz i have beene trying this for sooo long and i havent accomplished anything
Sponsor
Sponsor
Sponsor
sponsor
TheOneTrueGod




PostPosted: Tue Jun 06, 2006 8:00 pm   Post subject: (No subject)

You need to use trig. I believe you've had several problems similar to this, and you have allways gotten the same answer. Instead of posting here right away, go learn the material needed, try the question, then post here.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: