
-----------------------------------
mobin12
Thu Feb 09, 2012 7:19 pm

How do you get multiple enemies?
-----------------------------------
What is it you are trying to achieve?
I want to have multiple enemies when the score reaches 250 (So it's kind of like a difficulty)




%Set the screen size
setscreen ("graphics:900;550,nobuttonbar,offscreenonly")

var chars : array char of boolean
var enemy, player : array 1 .. 3 of int
enemy (1) := 15
enemy (2) := 15
enemy (3) := 1
player (1) := 450
player (2) := 275
player (3) := 1
var mx, my, b : int
var shockwave : array 1 .. 4 of int
shockwave (3) := 1
shockwave (4) := 0
var space : int := 0
var count : int := 3
var health : int := 215
var Intro : int := Pic.FileNew ("Game-Intro.jpg")
var Instructions : int := Pic.FileNew ("Game-Instructions.jpg")
var Background : int := Pic.FileNew ("Game-Background.jpg")
var Pause : int := Pic.FileNew ("Game-Pause.jpg")
var End : int := Pic.FileNew ("Game-End.jpg")
var font : int := Font.New ("DigifaceWide:46")
var font1 : int := Font.New ("Ethnocentric:13")
var score : int := 0
var s : string := ""
var rectangle : int

%THE INTRO
loop
    Pic.Draw (Intro, 0, 0, picMerge)
    mousewhere (mx, my, b)
    exit when mx > 288 and mx < 634 and my > 185 and my < 234 and b = 1
    View.Update
end loop

%THE INSTRUCTIONS
loop
    Pic.Draw (Instructions, 0, 0, picMerge)
    mousewhere (mx, my, b)
    exit when mx > 242 and mx < 694 and my > 104 and my < 170 and b = 1
    View.Update
    cls
end loop

%THE GAME
loop
    loop
        %Draw the Background for the game
        Pic.Draw (Background, 0, 0, picMerge)
        
        s:=intstr(score)
        Font.Draw ("score: ", 0, 507, font1, black)
        Font.Draw (s, 94, 507, font1, black)
        
        %Draw the player
        if player (3) = 1 then
            drawfilloval (player (1), player (2), 10, 10, 54)
            drawfilloval (player (1), player (2), 8, 8, 55)
        end if
        
        %Draw the enemy
        if enemy (3) = 1 then
            drawfilloval (enemy (1), enemy (2), 7, 7, 41)
        end if

        %Randomly place the enemy in the 'ENEMY BAY'
        randint (rectangle,1,4)
        if enemy (3) = 0 and rectangle = 1 then
            randint (enemy (1),7,893)
            randint (enemy (2),7,30)
            drawfilloval (enemy (1), enemy (2), 7, 7, 41)
            enemy (3) := 1
        elsif enemy (3) = 0 and rectangle = 2 then
            randint (enemy (1),7,29)
            randint (enemy (2),38,513)
            drawfilloval (enemy (1), enemy (2), 7, 7, 41)
            enemy (3) := 1
        elsif enemy (3) = 0 and rectangle = 3 then
            randint (enemy (1),37,893)
            randint (enemy (2),491,513)
            drawfilloval (enemy (1), enemy (2), 7, 7, 41)
            enemy (3) := 1
        elsif enemy (3) = 0 and rectangle = 4 then
            randint (enemy (1),870,893)
            randint (enemy (2),38,483)
            drawfilloval (enemy (1), enemy (2), 7, 7, 41)
            enemy (3) := 1
        end if

        Input.KeyDown (chars)
        %Player controls
        if chars ('a') and player (1) > 48 then
            player (1) := player (1) - 2
        end if
        if chars ('d') and player (1) < 851 then
            player (1) := player (1) + 2
        end if
        if chars ('w') and player (2) < 472 then
            player (2) := player (2) + 2
        end if
        if chars ('s') and player (2) > 49 then
            player (2) := player (2) - 2
        end if

        % Attempt on enemy follow
        if player (1) > enemy (1) then
            enemy (1) := enemy (1) + 1
        end if
        if player (1) < enemy (1) then
            enemy (1) := enemy (1) - 1
        end if
        if player (2) > enemy (2) then
            enemy (2) := enemy (2) + 1
        end if
        if player (2) < enemy (2) then
            enemy (2) := enemy (2) - 1
        end if

        %Shockwave
        if chars (' ') and count > 0 and space = 0 then
            shockwave (1) := player (1)
            shockwave (2) := player (2)
            shockwave (3) := 1
            shockwave (4) := 1
            count := count - 1
            space := 1
        end if
        if not chars (' ') then
            space := 0
        end if

        if chars ('e') then
            Pic.Draw (Pause, 0, 0, picMerge)
            Input.Pause
        end if
        
        %Display amount of shockwaves that are left
        if count = 3 then
            drawoval (198, 538, 7, 7, 39)
            drawoval (198, 538, 8, 8, 39)
            drawoval (222, 538, 7, 7, 39)
            drawoval (222, 538, 8, 8, 39)
            drawoval (245, 538, 7, 7, 39)
            drawoval (245, 538, 8, 8, 39)
        end if
        if count = 2 then
            drawoval (198, 538, 7, 7, 39)
            drawoval (198, 538, 8, 8, 39)
            drawoval (222, 538, 7, 7, 39)
            drawoval (222, 538, 8, 8, 39)
        end if
        if count = 1 then
            drawoval (198, 538, 7, 7, 39)
            drawoval (198, 538, 8, 8, 39)
        end if
        if count = 0 then
        end if

        %Firing the bullets
        mousewhere (mx, my, b)
        if b = 1 then
            drawline (player (1), player (2), mx, my, 40)
        end if

        %Enemy collision with shockwave
        if round (sqrt (((player (1) - enemy (1)) ** 2) + (player (2) - enemy (2)) ** 2))  216 and mx < 389 and my > 183 and my < 271 and b = 1 then
            %Set the variables
            enemy (1) := 15
            enemy (2) := 15
            enemy (3) := 1
            player (1) := 450
            player (2) := 275
            player (3) := 1
            count := 3
            health := 215
            score := 0
            exit
        end if
        
        %Close the game if 'EXIT' is clicked
        if mx > 522 and mx < 692 and my > 200 and my < 257 and b = 1 then
            Window.Close (defWinID)
        end if
    end loop
end loop



Please specify what version of Turing you are using
Turing 1.4.1

The code is also in the 'zip' file

-----------------------------------
Dragon20942
Fri Mar 02, 2012 7:38 pm

RE:How do you get multiple enemies?
-----------------------------------
Try using flexible arrays. They're arrays that can have their bounds changed. Look for em in the tutorials.

-----------------------------------
mobin12
Fri Mar 02, 2012 9:16 pm

RE:How do you get multiple enemies?
-----------------------------------
it's ok i found out how to do it.
This was a double post by accident.
But thanks anyways.
