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

Username:   Password: 
 RegisterRegister   
 Sprintes/Forks/
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tallguy




PostPosted: Mon Jun 01, 2009 8:23 am   Post subject: Sprintes/Forks/

So my group and I are working on our final project, a star wars sprint game, we are having problems with

-forking our process together (flicker free)

-collision dection (troopers suppose to stop 75 pikels away from dooku)

-troopers shooting on their on accord once they are 75 pikels away

anyone help???
any suggestions



Working on.zip
 Description:

Download
 Filename:  Working on.zip
 Filesize:  980.83 KB
 Downloaded:  51 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
tjmoore1993




PostPosted: Tue Jun 02, 2009 9:10 am   Post subject: RE:Sprintes/Forks/

This is what I've got so far, I am too sick to go on.

Walkman procedure (process fails)
Turing:
loop
        Input.KeyDown (chars) %starts the keyboard command
        if chars (KEY_RIGHT_ARROW) then %using the right arrow key
            if chars (KEY_RIGHT_ARROW) then
                x := x + 20 %movement isadded by 10 pixels
                z := 1 %becomes one - used for when blocking
                if x > 450 then %when charecter reaches the farest that hecan go
                    x := 450
                end if
            end if
            for a : 1 .. 13 %cals the array
                clear %Background
                Pic.Draw (dooku_walk (a), x, y, picMerge) %drawsthecharector at the variable point, merging it in with the background
                View.Update %update the screen
                delay (20)
            end for
        end if
        if chars (KEY_LEFT_ARROW) then %using the left arrow key
            if chars (KEY_LEFT_ARROW) then
                x := x - 20
                z := 2
                if x < 150 then
                    x := 150
                end if
            end if
            for a : 1 .. 13
                clear
                Pic.Draw (dooku_walkM (a), x + 8, y, picMerge)
                View.Update
                delay (20)
            end for
        end if
        if chars (KEY_DOWN_ARROW) and z = 1 then %down key
            loop
                clear
                Pic.Draw (dooku_block, x, y, picMerge) %draws the blocking picture
                View.Update
                delay (10)
                Input.KeyDown (chars)
                exit when chars (KEY_DOWN_ARROW) not= true
            end loop
            clear
            %  View.Update
            Pic.Draw (dooku_stand, x, y, picMerge)
            View.Update
        elsif chars (KEY_DOWN_ARROW) and z = 2 then %draws the mirror image of the blocking image
            loop
                clear
                Pic.Draw (dooku_blockM, x, y, picMerge)
                View.Update
                delay (25)
                Input.KeyDown (chars)
                exit when chars (KEY_DOWN_ARROW) not= true
            end loop
            clear
            %View.Update
            Pic.Draw (dooku_stand2, x, y, picMerge)
            View.Update
        end if
        if chars (' ') and z = 1 then %if space bar is pressed
            for b : 1 .. 10
                clear
                Pic.Draw (dooku_slash (b), x, y, picMerge)
                View.Update
                delay (50)
            end for
        elsif chars (' ') and z = 2 then
            for b : 1 .. 10
                clear
                Pic.Draw (dooku_slashM (b), x, y, picMerge)
                View.Update
                delay (50)
            end for
        end if
        if chars (KEY_UP_ARROW) then
            loop
                x2 := x2 + 2
                if x2 = x and chars (KEY_DOWN_ARROW) and z = 2 then
                    loop
                        x2 := x2 - 2
                        drawfilloval (x2, y2, 5, 1, brightred)
                        drawfilloval (x2 + 10, y2, 5, 1, 82)
                        exit when x2 < 0
                        View.Update
                        delay (1)
                    end loop
                elsif x2 = x then
                    health := health - 20
                    maxhealth := maxhealth - 1
                    if maxhealth = -1 then
                        delay (50)
                        return
                    end if
                    x2 := 0
                    y2 := 144
                    drawfilloval (x2 + x - 6, y2, 10, 1, 82)
                    clearhealth
                    View.Update
                    exit
                end if
                drawfilloval (x2, y2, 5, 1, brightred)
                drawfilloval (x2 - 10, y2, 5, 1, 82)
                if x2 < 0 or x2 > maxx then
                    x2 := 0
                    y2 := 144
                    exit
                end if
                View.Update
                delay (1)
            end loop
        end if
    end loop


Turing:


Also your down key wasn't working, check it out now Wink
tjmoore1993




PostPosted: Tue Jun 02, 2009 9:21 am   Post subject: RE:Sprintes/Forks/

To add, you really should think about revising the code a bit, to ensure that it is being done right because you could really turn that into an easy 100 lined code or 200 minimum. Smile
Tallguy




PostPosted: Tue Jun 02, 2009 9:24 am   Post subject: RE:Sprintes/Forks/

kk thanks man

any ideas about the forking problems
tjmoore1993




PostPosted: Tue Jun 02, 2009 12:35 pm   Post subject: RE:Sprintes/Forks/

Ideas? Well, just don't fork period.
Tallguy




PostPosted: Tue Jun 02, 2009 12:42 pm   Post subject: RE:Sprintes/Forks/

ummm er okay, then how would i get two procedures to run at the same time?
TheGuardian001




PostPosted: Tue Jun 02, 2009 3:24 pm   Post subject: Re: Sprintes/Forks/

You don't run them at the same time, you run them sequentially.

Instead of looping inside of your procedure, you have a main loop in your program which will run each procedure in order.

For example

code:

proc Move1
    Input.KeyDown(keys)
    if left then
        move left
    elsif right then
        move right
    end if
end Move1

proc Move2
    Input.KeyDown(keys)
    if a then
        move left
    elsif d then
        move right
    end if
end Move2

%MAIN LOOP

loop
Move1
Move2
View.Update
cls
end loop


each section will run through one repetition, then move on to the next procedure. It alternates between moving each of them one space at a time.
Tallguy




PostPosted: Wed Jun 03, 2009 11:39 am   Post subject: Re: Sprintes/Forks/

@ the TheGuardian001

kk i did wat you suggested
-not working!!

anyo one have any ideas? still can't combine the troopers walking with dooku walking



Object Oriented.t
 Description:
ONLY THE MAIN PROGRAM< PUT INTO FILE WITH THE PICTURES< SAME SPOT AS THE OTHER TURING FILE

Download
 Filename:  Object Oriented.t
 Filesize:  6.11 KB
 Downloaded:  95 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Wed Jun 03, 2009 2:48 pm   Post subject: Re: Sprintes/Forks/

Well, for one thing, you're only ever drawing dooku when the arrow keys are pressed. If you want him to be visible all the time, the Pic.Draw Call shouldn't be inside the input check. If the keys are not pressed, you should check which way he is facing and draw the correct direction picture (dooku_walk (1) / dooku_walkM (1))

For another, when I said that you shouldn't loop inside your procedure, I mean you really should only have the one main loop. outside of your procedure. If you loop inside of a procedure, the program won't progress past that point. For loops are included in this. Do the for loop manually so that only one frame is drawn per repetition instead of all of them. Otherwise, the trooper will have all of his frames drawn at the same time.

instead of
Turing:

if chars (KEY_LEFT_ARROW) then     %using the left arrow key
        if chars (KEY_LEFT_ARROW) then
            x := x - 20
            z := 2
            if x < 150 then
                x := 150
            end if
        end if
        for a : 1 .. 13    %NO! LOOP IN PROCEDURE BAD! NO LOOPS.
            clear
            Pic.Draw (dooku_walkM (a), x + 8, y, picMerge)
            View.Update
            delay (20)
        end for
    end if


you will need something more like

code:

var currentFrame : int := 1

proc dooku
    if left arrow then %LEFT ARROW HIT
        draw dooku_walk (currentFrame)  %DRAW CURRENT
        currentFrame:= currentFrame + 1  %INCREASE CURRENT
        if currentFrame > maxframes then  %MAKE SURE WE DON'T GO PAST THE END
            currentFrame := 1  %RESET IF WE DID
        end if
        Update  %UPDATE SCREEN
    elsif not left arrow then  %THEY LET GO
        currentFrame := 1  %RESET
    end if
end dooku %KEEP GOING. NOT STUCK IN THIS PROCEDURE.


you will need to change every time you used a loop / for loop to something like that. That way, it will draw one frame of each character each time the loop runs, and the animation will be smooth.

For regular loops (like your block one) you will need to simply set a variable to say if he's blocking. Ie:

code:

if down arrow then
    blocking := true
end if

%Stuff....
%more stuff...

if blocking then
    draw dooku_block
end if

tjmoore1993




PostPosted: Wed Jun 03, 2009 3:02 pm   Post subject: RE:Sprintes/Forks/

This is my way of doing it Wink

Posted Image, might have been reduced in size. Click Image to view fullscreen.
Tallguy




PostPosted: Wed Jun 03, 2009 7:54 pm   Post subject: RE:Sprintes/Forks/

@ TheGuardian001

woe!! okay, i'll trying doing wat you suggested, a lot of work....

@tjmoore1993

so confused
Tallguy




PostPosted: Fri Jun 05, 2009 8:17 am   Post subject: Re: Sprintes/Forks/

TheGuardian001 wrote:

Well, for one thing, you're only ever drawing dooku when the arrow keys are pressed. If you want him to be visible all the time, the Pic.Draw Call shouldn't be inside the input check. If the keys are not pressed, you should check which way he is facing and draw the correct direction picture (dooku_walk (1) / dooku_walkM (1))

For another, when I said that you shouldn't loop inside your procedure, I mean you really should only have the one main loop. outside of your procedure. If you loop inside of a procedure, the program won't progress past that point. For loops are included in this. Do the for loop manually so that only one frame is drawn per repetition instead of all of them. Otherwise, the trooper will have all of his frames drawn at the same time.

instead of
Turing:

if chars (KEY_LEFT_ARROW) then     %using the left arrow key
        if chars (KEY_LEFT_ARROW) then
            x := x - 20
            z := 2
            if x < 150 then
                x := 150
            end if
        end if
        for a : 1 .. 13    %NO! LOOP IN PROCEDURE BAD! NO LOOPS.
            clear
            Pic.Draw (dooku_walkM (a), x + 8, y, picMerge)
            View.Update
            delay (20)
        end for
    end if


you will need something more like

code:

var currentFrame : int := 1

proc dooku
    if left arrow then %LEFT ARROW HIT
        draw dooku_walk (currentFrame)  %DRAW CURRENT
        currentFrame:= currentFrame + 1  %INCREASE CURRENT
        if currentFrame > maxframes then  %MAKE SURE WE DON'T GO PAST THE END
            currentFrame := 1  %RESET IF WE DID
        end if
        Update  %UPDATE SCREEN
    elsif not left arrow then  %THEY LET GO
        currentFrame := 1  %RESET
    end if
end dooku %KEEP GOING. NOT STUCK IN THIS PROCEDURE.


you will need to change every time you used a loop / for loop to something like that. That way, it will draw one frame of each character each time the loop runs, and the animation will be smooth.

For regular loops (like your block one) you will need to simply set a variable to say if he's blocking. Ie:

code:

if down arrow then
    blocking := true
end if

%Stuff....
%more stuff...

if blocking then
    draw dooku_block
end if




okay tried doing wat you said, attached is our attempt, some problems
-when no keyboard is ressed boolean problems (currently commented out)
-would i do the same thing with the troopers walking in?
Tallguy




PostPosted: Fri Jun 05, 2009 8:18 am   Post subject: Re: Sprintes/Forks/

TheGuardian001 wrote:

Well, for one thing, you're only ever drawing dooku when the arrow keys are pressed. If you want him to be visible all the time, the Pic.Draw Call shouldn't be inside the input check. If the keys are not pressed, you should check which way he is facing and draw the correct direction picture (dooku_walk (1) / dooku_walkM (1))

For another, when I said that you shouldn't loop inside your procedure, I mean you really should only have the one main loop. outside of your procedure. If you loop inside of a procedure, the program won't progress past that point. For loops are included in this. Do the for loop manually so that only one frame is drawn per repetition instead of all of them. Otherwise, the trooper will have all of his frames drawn at the same time.

instead of
Turing:

if chars (KEY_LEFT_ARROW) then     %using the left arrow key
        if chars (KEY_LEFT_ARROW) then
            x := x - 20
            z := 2
            if x < 150 then
                x := 150
            end if
        end if
        for a : 1 .. 13    %NO! LOOP IN PROCEDURE BAD! NO LOOPS.
            clear
            Pic.Draw (dooku_walkM (a), x + 8, y, picMerge)
            View.Update
            delay (20)
        end for
    end if


you will need something more like

code:

var currentFrame : int := 1

proc dooku
    if left arrow then %LEFT ARROW HIT
        draw dooku_walk (currentFrame)  %DRAW CURRENT
        currentFrame:= currentFrame + 1  %INCREASE CURRENT
        if currentFrame > maxframes then  %MAKE SURE WE DON'T GO PAST THE END
            currentFrame := 1  %RESET IF WE DID
        end if
        Update  %UPDATE SCREEN
    elsif not left arrow then  %THEY LET GO
        currentFrame := 1  %RESET
    end if
end dooku %KEEP GOING. NOT STUCK IN THIS PROCEDURE.


you will need to change every time you used a loop / for loop to something like that. That way, it will draw one frame of each character each time the loop runs, and the animation will be smooth.

For regular loops (like your block one) you will need to simply set a variable to say if he's blocking. Ie:

code:

if down arrow then
    blocking := true
end if

%Stuff....
%more stuff...

if blocking then
    draw dooku_block
end if




okay tried doing wat you said, attached is our attempt, some problems
-when no keyboard is ressed boolean problems (currently commented out)
-would i do the same thing with the troopers walking in?



Object Oriented working on.t
 Description:

Download
 Filename:  Object Oriented working on.t
 Filesize:  2.33 KB
 Downloaded:  55 Time(s)

TheGuardian001




PostPosted: Fri Jun 05, 2009 2:49 pm   Post subject: Re: Sprintes/Forks/

You have the right idea for no keys pressed, however chars(' ') checks spacebar, not a lack of input. you can use if not chars(KEY_LEFT_ARROW), which will check and make sure the left arrow is not pressed. Do the same for any other keys used.

Now, if you were to implement the code for drawing the character with the structure you have now, the program would run in this order (assuming no keys pressed).

code:

CheckInputRight
    No input
    Draw standing frame(right)
end

CheckInputLeft
    No input
    Draw standing frame(left)
end
Update


The problem with that is that you will only ever see the left facing frame. There is no actual need to use 2 separate procedures here, just a variable that will hold which way the player is currently facing. Try combining input procedures together in to one main input procedure.

And yes, you will have to do the same thing for the trooper, however in his procedure there is no need to check for input.
gunsnr1992




PostPosted: Tue Jun 09, 2009 11:58 am   Post subject: Re: Sprintes/Forks/

I am worki0ng with Tallguy on this starwars game i need some help with the entrance and boundaries for the troopers and getting them to walk in at the same time smoothley and stopping at a specific distance away from the main character.


Trooper_Walk_Both.t
 Description:
place in same root file as other program

Download
 Filename:  Trooper_Walk_Both.t
 Filesize:  2.54 KB
 Downloaded:  61 Time(s)

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  [ 15 Posts ]
Jump to:   


Style:  
Search: