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

Username:   Password: 
 RegisterRegister   
 Mario game help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
neufelni




PostPosted: Wed Jan 11, 2006 1:53 pm   Post subject: Mario game help

I am making a Super Mario game and I need some help. How do I get it so that Mario falls when he runs off an object. I have tried doing this but then Mario always falls completely off the screen as soon as the program starts.


Super Mario Bros.zip
 Description:

Download
 Filename:  Super Mario Bros.zip
 Filesize:  13.58 KB
 Downloaded:  137 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Wed Jan 11, 2006 2:51 pm   Post subject: (No subject)

This code is just a disaster man. Your 2d array should be in some kind of text file. Also when you're making that text file dont use only number, use letters as well, even symbols. That way your 2d map is legible and doesn't get distorted with double digit numbers.

code:

1, 0, 0, r, t, q, 0, 1, g
2, 14, 15, 22, 14, 3, 0, 0, 56

see how hard that is to line up? Times that by 20 (i.e. your program in the future)

Secondly, fix that 1000 chr long exit when x 2, that is inside a proces'd loop. Ditch the process, they'll crap you over. Change them to normal procedure. Just use the process to play music.

Lastly get rid of getch, use only Input.KeyDown, there's not real point for getch with this if ur usin Input.

Not to rip on your program, but this coding is gonna get ugly real fast.

Oh, and here's your solution (ur prolly gonna slap urself)

code:

procedure fall
if level1(floor (marioy / 20), floor (mariox / 20 + (picnum - 1) * 20)) = 0 then
marioy -=2
end if
end fall

Put that somewhere, then put " fall " somewhere in ur loop.
neufelni




PostPosted: Thu Jan 12, 2006 12:02 pm   Post subject: (No subject)

How can I shorten that long exit when line?
jamonathin




PostPosted: Thu Jan 12, 2006 1:39 pm   Post subject: (No subject)

Try and figure it out first, before you copy and paste the below code, but what you should do is assign those numbers to an array (the numbers that tell you when to exit loop) and have a for loop run through those numbers, and if that condition matches the number, bam, ur done.

Now im not sure how much this slows down ur program (shouldn't) but for some reason your program is runnign really slow on this comp (schools), but anyways, try it out first, then if u give up use the code.

code:
process mariojump
    loop
        getch (jump)
        % C is for CEIL (first loop)
        % F is for FLOOR (sencond loop)
        var exitWhenNumbersC : array 1 .. 4 of int := init (2, 10, 11, 12)
        var exitWhenNumbersF : array 1 .. 6 of int := init (1, 2, 10, 11, 12, 13)
        var exitNow : boolean := false
        %Tells loop when to exit
        if jump = (KEY_UP_ARROW) then
            inair := true
            maxheight := marioy + 80
            loop
                marioy := marioy + 2
                delay (2)
                exit when marioy = maxheight or marioy + 20 = 200
                for i : 1 .. upper (exitWhenNumbersC) % 4
                    if level1 (ceil (marioy / 20), floor (mariox / 20)) = exitWhenNumbersC (i) or level1 (ceil (marioy / 20), floor ((mariox + 20) / 20)) = exitWhenNumbersF (i) then
                        exitNow := true
                        exit
                    end if
                end for
                exit when exitNow
            end loop
            delay (20)
            loop
                marioy := marioy - 2
                delay (2)
                if marioy > 0 and marioy < 200 then
                    for i : 1 .. upper (exitWhenNumbersF) % which is 6
                        if level1 (floor (marioy / 20), floor (mariox / 20 + (picnum - 1) * 20)) = exitWhenNumbersF (i) or level1 (floor (marioy / 20), floor ((mariox + 20) / 20 + (picnum - 1) * 20))
                                = exitWhenNumbersF (i) then
                            exitNow := true
                            exit
                        end if
                    end for
                    exit when exitNow
                end if
            end loop
        end if
        inair := false
    end loop
end mariojump
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  [ 4 Posts ]
Jump to:   


Style:  
Search: