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

Username:   Password: 
 RegisterRegister   
 HELP! How do I get the koopas to flip? (Mario Game)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Gathard




PostPosted: Fri Jan 09, 2015 2:30 pm   Post subject: HELP! How do I get the koopas to flip? (Mario Game)

What is it you are trying to achieve?
Trying to get it so when mario hits the koopas from the bottom they flip, once they flip they respawn after a few seconds.


What is the problem you are having?
Cannot figure out how to do this, been trying for almost 1 week.


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


Turing:


setscreen ("graphics: max,max")
setscreen ("offscreenonly")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Variables%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var background : int := Pic.FileNew ("background.bmp")
var marioLeft : int := Pic.FileNew ("mario left.bmp")
var marioStill : int := Pic.FileNew ("still.bmp")
var marioStillRight : int := Pic.FileNew ("stillright.bmp")
var marioRight : int := Pic.FileNew ("movingright.bmp")
var chars : array char of boolean
var mariox : int := 488
var marioy : int := 111
var marioy2 : int := 111
var dir : string := "r"

var jump : string := "n"
var jumpv : int := 0
var count : int := 1
var fall : string := "n"
var kfall : string := "k"
var kfall2 : string := "k2"
var koopaL : int := Pic.FileNew ("KoopaL.bmp")
var koopaR : int := Pic.FileNew ("KoopaR.bmp")
var koopax2 : int := 133
var koopay2 : int := 590
var koopax : int := 733
var koopay : int := 590
var score : int := 0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%BACKGROUND%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Pic.Draw (background, 0, 0, 0)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%PARAMETERS%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc drawlines
    %---LEFT SIDE---
    drawline (0, 95, 975, 110, yellow) %Ground Floor
    drawfillbox(0, 95, 975, 110, yellow)
    %Tier 1 Start
    drawline (0, 207, 370, 207, yellow) %Tier 1, Platform 1, Bottom
    drawline (370, 207, 370, 228, yellow) %Tier 1, Platform 1, Side
    drawline (370, 228, 0, 228, yellow) %Tier 1, Platform 1, Top
    drawfillbox(0, 207, 370, 228, yellow)
    %Tier 1 End...

    drawline (3, 228, 3, 473, yellow) %Black Space Between Tier 3 Platform 1, and Tier 1 Platform 1

    %Tier 2 Start...

    drawline (3, 328, 147, 328, yellow) %Tier 2, Platform 1, Bottom
    drawline (147, 329, 147, 345, yellow) %Tier 2, Platform 1, Side
    drawline (147, 345, 3, 345, yellow) % Tier 2, Platform 1, Top
    drawfillbox(3, 328, 147, 345, yellow) 
    %Tier 2 End...

    %Tier 3 Start
    drawline (3, 473, 388, 473, yellow) %Tier 3, Platform 1, Bottom
    drawline (388, 473, 388, 492, yellow) %Tier 3, Platform 1, Side
    drawline (388, 492, 3, 492, yellow) % Tier 3, Platform 1, Top
    drawfillbox(3, 473, 388, 492, yellow)
    %Tier 3 End...

    %---LEFT SIDE END---


    %MIDDLE PLATFORMS
    drawline (265, 354, 710, 354, yellow) %Tier 2, Platform 2, Bottom
    drawline (265, 354, 265, 370, yellow) %Tier 2, Platform 2, Left Side
    drawline (710, 354, 710, 370, yellow) %Tier 2, platform 2, Right Side
    drawline (264, 370, 710, 370, yellow) %Tier 2, Platform 2, Top
    %MIDDLE PLATFORMS END...

    %---RIGHT SIDE---

    %Tier 1 Start
    drawline (975, 207, 606, 207, yellow) %Tier 1, Platform 2, Bottom
    drawline (606, 207, 606, 228, yellow) %Tier 1, Platform 2, Side
    drawline (606, 228, 975, 228, yellow) %Tier 1, Platform 2, Top
    %Tier 1 End...

    drawline (975 - 3, 228, 975 - 3, 473, yellow) %Black Space Between Tier 3 Platform 1, and Tier 1 Platform 1

    %Tier 2 Start
    drawfillbox(825,328,972,345,yellow)
    drawline (975 - 3, 328, 825, 328, yellow) %Tier 2, Platform 3, Bottom
    drawline (825, 329, 825, 345, yellow) %Tier 2, Platform 3, Side
    drawline (825, 345, 975 - 3, 345, yellow) % Tier 2, Platform 3, Top
    %Tier 2 End...

    %Tier 3 Start
    drawline (975 - 3, 473, 975 - 388, 473, yellow) %Tier 3, Platform 2, Bottom
    drawline (975 - 388, 473, 975 - 388, 492, yellow) %Tier 3, Platform 2, Side
    drawline (975 - 388, 492, 975 - 3, 492, yellow) % Tier 3, Platform 2, Top
    drawfillbox(975 - 3, 473, 975 - 388, 492, yellow)
    %Tier 3 End...

    %Pipe bottom right
    drawline (828, 200, 975, 200, green) %top of the pipe
    drawline (832, 125, 832, 195, green) %Entrance of pipe
    drawline (828, 135, 975, 135, green) %bottom of pipe
   

    %Pipe bottom left
    drawline (0, 200, 147, 200, green) %top of the pipe
    drawline (145, 125, 145, 195, green) %Entrance of pipe
    drawline (0, 135, 147, 135, green) %bottom of pipe

    %Pipe top right
    drawline (810, 600, 865, 600, green) %bottom of pipe
    drawline (810, 1000, 810, 600, green) %Entrance of pipe
    drawline (866, 600, 866, 475, green) %bottom of pipe

    %Pipe top left
    drawline (105, 600, 160, 600, green) %bottom of pipe
    drawline (160, 1000, 160, 600, green) %Entrance of pipe
    drawline (105, 600, 105, 475, green) %bottom of pipe



end drawlines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%SUBROUTINE%%%%%%%%%%%%%%%%%%%%%%%%%%%

proc timer


end timer

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CODE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
put ""


Pic.Draw (marioStill, mariox, marioy, picMerge)
var mydelay : int := 0
process bgmusic
Music.PlayFile ("underground.mp3")
end bgmusic
fork bgmusic

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%MARIO LOOP%%%%%%%%%%%%%%%%%%%%%%%%%%%%
loop
    Pic.Draw (background, 0, 0, 0)
    Input.KeyDown (chars)
    if chars (KEY_LEFT_ARROW) then
        mariox -= 1
        dir := "l"
    end if
    Input.KeyDown (chars)
    if chars (KEY_RIGHT_ARROW) then
        mariox += 1
        dir := "r"
    end if
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) and jump = "n" then
        jump := "y"
        jumpv := 4
        dir := "u"
        mydelay := 0
    end if
    if jump = "y" then
        mydelay += 1
        marioy := marioy + jumpv
        if mydelay mod 20 = 0 then
            jumpv -= 1
        end if
    end if
    if marioy < 100 then
        jump := "n"
    end if
    if dir = "l" then
        Pic.Draw (marioLeft, mariox, marioy, picMerge)
    end if
    if dir = "u" then
        Pic.Draw (marioStillRight, mariox, marioy, picMerge)
    elsif dir = "r" then
        Pic.Draw (marioRight, mariox, marioy, picMerge)
    end if
    if mariox <= 2 then
        mariox := 935
    elsif mariox >= 935 then
        mariox := 8
    end if
    drawlines

    if marioy < 110 then
        marioy := 110
        jump:="n"
    end if
    %%%%%%%%%Koopa start%%%%%%%%%%%%
    koopax2 := koopax2 + 1   
    koopax := koopax - 1
    Pic.Draw (koopaR, koopax2, koopay2, picMerge)
    Pic.Draw (koopaL, koopax, koopay, picMerge)
    if koopax2 <= 2 then
        koopax2 := 700             %%%%% KOOPA2 WRAP AROUND
    elsif koopax2 >= 865 then
        koopax2 := 8
    end if
    if koopax <= 2 then
        koopax := 700                %%%%% KOOPA WRAP AROUND
    elsif koopax >= 865 then
        koopax := 8
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%GRAVITY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    drawlines
    % locate (1, 1)
    % put count ..
    % locate (2, 1)
    % put jumpv
    % locate (3, 1)
    % put marioy
    % locate (4, 1)
    % put jump
    count := count + 1 %increases x by 1
    View.Update
    for x : 1 .. 50
        if whatdotcolor (koopax2 + x, koopay2 - 1) = yellow then
            kfall := "k"
        end if
        if whatdotcolor (koopax2 + x, koopay2 + 73) = yellow then
            kfall := "k"
        end if
        if whatdotcolor (koopax2 + x, koopay2 - 1) not= yellow then
            kfall := "y"
        end if
        if whatdotcolor (koopax2 + x, koopay2 - 1) not= yellow then
            kfall := "y"
        end if
    end for

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    for x : 1 .. 50
        if whatdotcolor (koopax + x, koopay - 1) = yellow then
            kfall2 := "k2"
        end if
        if whatdotcolor (koopax + x, koopay + 73) = yellow then
            kfall2 := "k2"
        end if
        if whatdotcolor (koopax + x, koopay - 1) not= yellow then
            kfall2 := "y"
        end if
        if whatdotcolor (koopax + x, koopay - 1) not= yellow then
            kfall2 := "y"
        end if
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    end for
    for x : 1 .. 50
   
        if whatdotcolor (mariox + x, marioy - 1) = yellow then
            jump := "n"
            fall := "n"
            jumpv := 0
        end if
        if whatdotcolor (mariox + x, marioy + 73) = yellow then
            jump := "no"
            fall := "y"
        end if
        if whatdotcolor (mariox + x, marioy - 1) not= yellow and jump = "n" then
            jump := "n"
            fall := "y"
        end if
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    end for
    if koopay < 110 then
        koopay := 100
    end if
    if koopay2 < 110 then                  % stops from falling through ground
        koopay2 := 100
    end if
    if kfall = "y" then
        koopay2 := koopay2 - 1         % Falling for left koopa
    end if
    if kfall2 = "y" then
        koopay := koopay - 1         % falling for right koopa
    end if
    if fall = "y" then
        marioy := marioy - 1         % falling for Mario
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    if mariox >= koopax and marioy >= koopay and mariox < koopax + 70 and marioy < koopay + 70 then
       exit           %%%%% Marios death
    end if

    if mariox >= koopax2 and marioy >= koopay2 and mariox < koopax2 + 70 and marioy < koopay2 + 70 then
       exit           %%%%% Marios death
    end if

end loop

%%%%%%%%%%%%%%%%%%%%%%%%%End of Koopa and Mario Loop%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cls
put "YOU DIED, GAME OVER"
put " your score is ", count

View.Update




Please specify what version of Turing you are using
4.1.1

P.S For a class final![/list]
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Sat Jan 10, 2015 5:03 am   Post subject: RE:HELP! How do I get the koopas to flip? (Mario Game)

What do you mean by "flip"? Are you trying to have the koopa picture rotate 180 degrees over a duration of 1 second? If so, that would be fairly difficult to do.

In the actual game, koopa's retreat into their shells like so, which might be easier to do, as it's just replacing the koopa's picture.

For the latter, you could keep track of what "state" the koopa is in. Eg:

Turing:

var koopaState := "alive"


Then when the koopa dies, change it to "dead". You can then have conditionals around where you draw the koopa to check if the koopa is alive or dead and then draw the appropriate picture.

You'll want to keep track of how long the koopa has been in the state.

Turing:

var koopaStateFrameCount := 0

loop
    koopaStateFrameCount += 1
    if marioKilledTheKoopa() then
        koopaState := "dead"
        koopaStateFrameCount := 0
    end if
end loop


Then you can check if koopaStateFrameCount is 90 (Assuming a delay of 33 millisecond for 30 FPS) which would mean 90 frames have passed (or 3 seconds at 30 FPS). If that much time has passed, you can reinitialize the koopa to be alive.
Gathard




PostPosted: Mon Jan 12, 2015 1:37 pm   Post subject: Re: RE:HELP! How do I get the koopas to flip? (Mario Game)

Zren @ Sat Jan 10, 2015 5:03 am wrote:
What do you mean by "flip"? Are you trying to have the koopa picture rotate 180 degrees over a duration of 1 second? If so, that would be fairly difficult to do.

In the actual game, koopa's retreat into their shells like so, which might be easier to do, as it's just replacing the koopa's picture.

For the latter, you could keep track of what "state" the koopa is in. Eg:

Turing:

var koopaState := "alive"


Then when the koopa dies, change it to "dead". You can then have conditionals around where you draw the koopa to check if the koopa is alive or dead and then draw the appropriate picture.

You'll want to keep track of how long the koopa has been in the state.

Turing:

var koopaStateFrameCount := 0

loop
    koopaStateFrameCount += 1
    if marioKilledTheKoopa() then
        koopaState := "dead"
        koopaStateFrameCount := 0
    end if
end loop


Then you can check if koopaStateFrameCount is 90 (Assuming a delay of 33 millisecond for 30 FPS) which would mean 90 frames have passed (or 3 seconds at 30 FPS). If that much time has passed, you can reinitialize the koopa to be alive.


Right, i'd like them to flip/go into their shell the same way the actual game works, as for the other parts i think that'll work good just first need to make it so mario can somehow hit them, any suggestions? Very very very new to turing, thanks.
Zren




PostPosted: Mon Jan 12, 2015 7:54 pm   Post subject: RE:HELP! How do I get the koopas to flip? (Mario Game)

You're looking for Collision Detection. Specifically, rectangular collision detection. Look for it in the Turing Walkthrough.
Gathard




PostPosted: Tue Jan 13, 2015 2:18 pm   Post subject: Re: RE:HELP! How do I get the koopas to flip? (Mario Game)

Zren @ Mon Jan 12, 2015 7:54 pm wrote:
You're looking for Collision Detection. Specifically, rectangular collision detection. Look for it in the Turing Walkthrough.


Is there anyone I can pay to complete things for me? I'd just like someone to do it for me. Want a few more things coded aswell. thanks.

MOD WARNING: Asking for others to do your homework is academic dishonesty, plagiarism and a violation of the sites rules. Please refrain from making such posts or your account will be banned.
Insectoid




PostPosted: Tue Jan 13, 2015 10:59 pm   Post subject: RE:HELP! How do I get the koopas to flip? (Mario Game)

That's a quick way to get yourself banned from the site, bud. Do it yourself, like everyone else.
Gathard




PostPosted: Wed Jan 14, 2015 1:29 pm   Post subject: Re: RE:HELP! How do I get the koopas to flip? (Mario Game)

Insectoid @ Tue Jan 13, 2015 10:59 pm wrote:
That's a quick way to get yourself banned from the site, bud. Do it yourself, like everyone else.


I'd give credit... we're allowed to get 50% of help from someone anywhere anyone.... ive made the rest of the game. I don't have time to do it all on my own/learn.
Insectoid




PostPosted: Wed Jan 14, 2015 3:04 pm   Post subject: RE:HELP! How do I get the koopas to flip? (Mario Game)

Quote:
I don't have time to do it all on my own/learn.


You do have the time. You're in high school. Time pretty much all you have, and learning is what you should be spending it on.

Quote:
we're allowed to get 50% of help from someone anywhere anyone


Ask a classmate then. Collision detection isn't hard. There are lots of tutorials about exactly that on this website. There is no reason not to do it yourself.
Sponsor
Sponsor
Sponsor
sponsor
Gathard




PostPosted: Thu Jan 15, 2015 1:29 pm   Post subject: Re: RE:HELP! How do I get the koopas to flip? (Mario Game)

Insectoid @ Wed Jan 14, 2015 3:04 pm wrote:
Quote:
I don't have time to do it all on my own/learn.


You do have the time. You're in high school. Time pretty much all you have, and learning is what you should be spending it on.

Quote:
we're allowed to get 50% of help from someone anywhere anyone


Ask a classmate then. Collision detection isn't hard. There are lots of tutorials about exactly that on this website. There is no reason not to do it yourself.


We all do different programs... and Yeah actually I don't have time. I have exams in under a week, I run a business and lots of other things.
Tony




PostPosted: Thu Jan 15, 2015 2:01 pm   Post subject: Re: RE:HELP! How do I get the koopas to flip? (Mario Game)

Gathard @ Thu Jan 15, 2015 1:29 pm wrote:
and Yeah actually I don't have time.

Time management is part of the learning process. If you are unable to find the time, and your classmates that have the same assignment and (for the most part) same exams coming up _do_ find the time -- don't you think the assignment grades should reflect that?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Thu Jan 15, 2015 3:03 pm   Post subject: RE:HELP! How do I get the koopas to flip? (Mario Game)

Quote:
We all do different programs


That doesn't matter. Odds are one of them is doing something very similar, or knows how to do what you're asking.
MatthewDaigneau




PostPosted: Thu Jan 15, 2015 3:07 pm   Post subject: RE:HELP! How do I get the koopas to flip? (Mario Game)

This will sound as useful as a tech support guy saying "Have you restarted the computer?", buuuuut, have you tried asking the teacher for help?
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  [ 12 Posts ]
Jump to:   


Style:  
Search: