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

Username:   Password: 
 RegisterRegister   
 need help spawning enemies
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Abbas_M




PostPosted: Sun Jan 17, 2010 7:14 pm   Post subject: need help spawning enemies

What is it you are trying to achieve?
im making a game that has a spaceship avoiding zombies to score points.


What is the problem you are having?
problem is i can figure out the code to make more than one zombies my current code is make one zombie that is moving toward the space ship but that zombies is being spawned constantly at different locations while its moving.



Describe what you have tried to solve this problem
Looked for tutorials for spawning enemies but found nothing


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


Turing:


var x1, x2, y1, y2, radius_1, radius_2, zombiey, zombiex : int

setscreen ("graphics:800;500, offscreenonly")



% SpaceShip Movement Command
procedure movement

    fork ingamemusic

    loop

        Input.KeyDown (chars)

        %Main Movement Seqeunce
        if chars (KEY_UP_ARROW) then
            y1 := y1 + 5
        end if
        if chars (KEY_DOWN_ARROW) then
            y1 := y1 - 5
        end if

        Pic.Draw (gamegalaxy, 3, -50, picMerge)

        %spawns zombies to attack spaceship
        randint (zombiey, -15, 419)
        Pic.Draw (zombie, zombiex, zombiey, picMerge)
        zombiex := zombiex - 1


        Pic.Draw (ship, x1, y1, picMerge)
        delay (2)

        if Math.Distance (x1, y1, zombiex, zombiey) < (radius_1 + radius_2) then
            put "Spaceship Crashed"
            Music.PlayFileStop
            exit
        end if

        View.UpdateArea (0, 0, maxx, maxy)
        cls

        %Boundrie to Up
        if y1 > 419 then
            y1 := y1 - 10
        end if

        %Boundrie to Down
        if y1 < -15 then
            y1 := y1 + 10
        end if

    end loop
end movement

movement




Please specify what version of Turing you are using
4.1.1

That one zombie is moving toward the space ship but being spawned over and over while it moves so its like spawning top to bottom at very quick speed giving the spaceship no hope to avoid the zombie.
Sponsor
Sponsor
Sponsor
sponsor
Turing_Gamer




PostPosted: Sun Jan 17, 2010 8:03 pm   Post subject: Re: need help spawning enemies

Deja vu...
Anyway, have you learned about array's?
That is the key to have multiple enemies.
And that Rand.Int should only happen when you destroy that specific zombie.
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: