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

Username:   Password: 
 RegisterRegister   
 [source] How to make bombs drop while player still play game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DanShadow




PostPosted: Sat Jan 03, 2004 8:47 pm   Post subject: [source] How to make bombs drop while player still play game

Mimi asked for a code, that allows a player to drop bombs, and have the bombs drop without disappearing while the character moves. So I thought, some other people may want to know how it is done, so here it is.
code:

var playerx, playery : int
playerx := 20
playery := 380
var key : string (1) := ""
var num, counter : int := 0
var bombx, bomby : array 1 .. 200 of int
for i : 1 .. 200
    bombx (i) := -20
    bomby (i) := -20
end for

loop
    setscreen ("offscreenonly")
    View.Update
    delay (5)
    num := num + 1
    Draw.FillBox (0, 0, maxx, maxy, 255)
    Draw.FillBox (playerx - 20, playery - 20, playerx + 20, playery + 20, 1)
    if hasch then
        getch (key)
    end if
    if key = (KEY_RIGHT_ARROW) and playerx < maxx - 10 then
        playerx := playerx + 6
    elsif key = (KEY_LEFT_ARROW) and playerx > 10 then
        playerx := playerx - 6
    end if
    for i : 1 .. 200
        if bomby (i) < 0 then
            bombx (i) := -20
            bomby (i) := -20
        end if
        if bombx (i) not= -20 and bomby (i) not= -20 then
            Draw.FillOval (bombx (i), bomby (i), 15, 15, 12)
            bomby (i) := bomby (i) - 18
        end if
    end for
    if counter >= 5 then
        if bombx (num) = -20 and bomby (num) = -20 then
            bombx (num) := playerx
            bomby (num) := playery - 15
            counter := 0
        end if
    end if
    counter := counter + 1
    if num = 199 then
        num := 0
    end if

end loop

Use it how you wish, if you can pick th rough the code. (Its not hard to do that) Ive used this kind of thing (with arrays) for multiple t hings, from this, to saving where bullets have been in a shooter game. Enjoy
Sponsor
Sponsor
Sponsor
sponsor
kalin




PostPosted: Wed Jan 21, 2004 4:04 pm   Post subject: (No subject)

Err...Interesting??
DanShadow




PostPosted: Wed Jan 21, 2004 8:41 pm   Post subject: (No subject)

nah..n ot really too interesting...I just submited it just in case anybody needed to know how to do it. Wink
kalin




PostPosted: Wed Jan 21, 2004 8:44 pm   Post subject: (No subject)

didn't you notice the '?'s' at the end of that????
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: