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

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




PostPosted: Tue Oct 18, 2011 5:19 pm   Post subject: monster pathing problem

What is it you are trying to achieve?
i am tring to get monsters to go in a path


What is the problem you are having?
they have trouble with the pathings


Describe what you have tried to solve this problem
took out turn count, but it made it worse


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

i found most of the code off this website and it did what i want it to do, so i decided to modify it to add pathing

Turing:

setscreen ("offscreenonly")
type mobSpecs :                        %records stats
    record
        x, y : int
        dead : boolean
        speedX, speedY : int
        turn : int
    end record
var enemy : flexible array 1 .. 0 of mobSpecs
var mobTime, mobNum : int := 0

loop
    for n : 1 .. upper (enemy) %number of enemys
        enemy (n).speedX := 0
        enemy (n).speedY := 1
        enemy (n).turn := 1
        if enemy (n).dead = false then     %if they are not dead
            if enemy (n).y = 100 and enemy (n).turn = 1 then     %pathing
                enemy (n).speedX := -1
                enemy (n).speedY := 0
                enemy (n).turn := 2
            end if
            if enemy (n).x = 300 and enemy (n).turn = 2 then
                enemy (n).speedX := 0
                enemy (n).speedY := -1
                enemy (n).turn := 3
            end if
            if enemy (n) > maxx then      %if they cross maxx
                enemy (n).dead := true     %they are dead
            end if

            put enemy (n).turn
            enemy (n).x -= enemy (n).speedX     %moves them
            enemy (n).y -= enemy (n).speedY
            Draw.FillBox (enemy (n).x, enemy (n).y, enemy (n).x + 5, enemy (n).y + 5, 12)     %draws them
        end if
    end for

    mobTime += 1
    if mobTime > 100 then
        for number : 1 .. upper (enemy)
            if enemy (number).dead = true then
                mobNum := number
                exit
            end if
        end for

        if mobNum = 0 then                    %if there are no mobs on the screen
            mobNum := upper (enemy) + 1       %draws mobs
            new enemy, mobNum
        end if

        enemy (mobNum).x := 50
        enemy (mobNum).y := maxy
        enemy (mobNum).dead := false
        mobNum := 0
        mobTime := 0
    end if
    drawline (300, 0, 300, maxy, black)     
    drawline (0, 250, maxx, 250, black)
    drawline (0, 100, maxx, 100, black)
    View.Update
    delay (5)
    cls
end loop




Please specify what version of Turing you are using
newest one
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Oct 18, 2011 7:43 pm   Post subject: Re: monster pathing problem

childplay534 @ Tue Oct 18, 2011 5:19 pm wrote:
i found most of the code off this website and it did what i want it to do, so i decided to modify it to add pathing

Well there's your problem.

If you don't fully understand the code you are modifying, there might be all kinds of subtle problems that you'd be running into. It might be best to put this code aside and write this part up yourself from scratch. If you understand your code, modifying it will be much simpler.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Beastinonyou




PostPosted: Tue Oct 18, 2011 7:54 pm   Post subject: Re: monster pathing problem

Tony @ Tue Oct 18, 2011 7:43 pm wrote:

If you don't fully understand the code you are modifying, there might be all kinds of subtle problems that you'd be running into. It might be best to put this code aside and write this part up yourself from scratch. If you understand your code, modifying it will be much simpler.


Couldn't have said it better.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: