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

Username:   Password: 
 RegisterRegister   
 Randomizing Procedures help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SeeknDestroy




PostPosted: Sat Jan 10, 2004 10:55 am   Post subject: Randomizing Procedures help

well im making this shooter game and in it i made a bg picture a process, and made 3 procedures, in the procedures, the bg process is forked and a picture of an enemy appears and i used the mousewhere function to have the picture disappear after u click on it or a delay for when u dont click it. after the procedure codes, i put in a loop, in the loop i have a randint funtion, and it randomly picks a number between 1-3, and when a number is chosen, it corresponding procedure is ran. but when i run my program, the different enemy pictures just appears randomly for a second and disappears again. can n e one plz help me? here's the code if it helps. plz keep in mind i am a noob to turing. thnx a lot

code:
var x, y, button, number, enemies, btn, updown : int
var win, win1 := 0
var winID : int
winID := Window.Open ("position:top;center,graphics:640;480")

randomize
process music %Shoot the enemies
    Music.PlayFile ("AFI - Sacrifice Theory.wav") %<Plays a background music
end music

% The level background
process bg1
    Pic.ScreenLoad ("level1.bmp", 0, 0, picCopy)
end bg1

procedure enemy1
    fork bg1
    mousewhere (x, y, button)
    Pic.ScreenLoad ("level1enemy1.bmp", 300, 345, picCopy)
    if x > 300 and x < 556 and y > 345 and y < 480 and button = 1 then
        win := win + 1
        win1 := win1 + 1
    end if
    delay (800)
    win := win - 1
    win1 := win1 + 1
end enemy1

procedure enemy2
    fork bg1 % The level background
    mousewhere (x, y, button)
    Pic.ScreenLoad ("level1enemy2.bmp", 0, 280, picCopy)
    win1 := win1 + 1
    if x > 0 and x < 196 and y > 280 and y < 415 and button = 1 then
        win := win + 1
        win1 := win1 + 1
    end if
    delay (800)
    win := win - 1
    win1 := win1 + 1
end enemy2

procedure enemy3
    fork bg1 % The background
    mousewhere (x, y, button)
    Pic.ScreenLoad ("level1enemy3.bmp", 150, 100, picCopy) %The third enemy
    win1 := win1 + 1
    if x > 150 and x < 346 and y > 100 and y < 235 and button = 1 then
        win := win + 1
        win1 := win1 + 1
    end if
    delay (800)
    win := win - 1
    win1 := win1 + 1
end enemy3

Pic.ScreenLoad ("level1.bmp", 0, 0, picCopy)
Pic.ScreenLoad ("beginbutton.bmp", 220, 205, picCopy)
buttonwait ("down", x, y, btn, updown)
if (220 <= x) and (x <= 420) and
        (205 <= y) and (y <= 275) then
    Pic.ScreenLoad ("level1.bmp", 0, 0, picCopy)
end if
loop
    fork music
    randint (enemies, 1, 3)
    if enemies = 1 then
        enemy1
    elsif enemies = 2 then
        enemy2
    elsif enemies = 3 then
        enemy3
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
SeeknDestroy




PostPosted: Sat Jan 10, 2004 12:32 pm   Post subject: (No subject)

plz...someone... plz help me Sad
Tony




PostPosted: Sat Jan 10, 2004 2:31 pm   Post subject: (No subject)

umm... you should put your Mouse.Where inside the loop. Because otherwise you're just checking if the user clicked just once Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
SeeknDestroy




PostPosted: Sat Jan 10, 2004 8:38 pm   Post subject: (No subject)

ok, thnx a lot!
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  [ 4 Posts ]
Jump to:   


Style:  
Search: