Computer Science Canada

My take on Mario

Author:  DifinityRJ [ Mon Jan 08, 2007 8:09 pm ]
Post subject:  My take on Mario

Hi, im in grade 10 and for my ISU i making a Mario game. This is my first year in programming, and Turing is my first language. Yes, it isn't exactly like Mario, i know. Also it isn't completely done, but i would like some constructive comments on how the game feels, and its fun factor for you. You move with arrow keys and jump with Space.

Note: This isn't a sidescroller, its basically rooms.

Author:  CodeMonkey2000 [ Mon Jan 08, 2007 8:38 pm ]
Post subject:  RE:My take on Mario

Thats pretty good. There are some problems with collisons though. Cant wait to see more updates.

Author:  DifinityRJ [ Mon Jan 08, 2007 8:41 pm ]
Post subject:  Re: My take on Mario

im using Math.Distance for my collision, is there any better way to do it?

Author:  CodeMonkey2000 [ Mon Jan 08, 2007 8:48 pm ]
Post subject:  RE:My take on Mario

Well I used my own collision function on my mario game(it's an updated verson of my program here) that checks if two images are colliding. The same function is used for level and enemy collision.

Author:  DifinityRJ [ Mon Jan 08, 2007 8:57 pm ]
Post subject:  Re: My take on Mario

I havent learnt record or functions or .floor, i dont even know what that is. Pretty much the code doesn't make any sense to me.

Author:  Clayton [ Mon Jan 08, 2007 9:03 pm ]
Post subject:  Re: My take on Mario

then take a look through the Turing Walkthrough at all of the great tutorials Very Happy a quick runthrough:

Records:

records are collections of data, meaning you can make them hold anything you want, ie:

Turing:

var foo :
    record :
        x, y :int
        name : string
    end record

foo.x := 5
foo.y := 10
foo.name := "bob"


Functions:

Functions are methods that compute new values from arguments passed to it, and return that value, ie:

Turing:

function foo (num, num2 : int) : int
    return num + num2
end foo

put foo (5, 5)

Author:  CodeMonkey2000 [ Mon Jan 08, 2007 9:03 pm ]
Post subject:  RE:My take on Mario

you can look at the turing tutorials for info on functions,records and Mario.floor is just a variable (it shows up as a predefied function at school for some reason). I dont get how you are using Math.Distance though. I would just use x,y comparison.

Author:  Clayton [ Mon Jan 08, 2007 9:06 pm ]
Post subject:  Re: My take on Mario

sorry, my function code should have been as follows:

Turing:

function foo (num, num2 : int) : int
    result num + num2
end foo

put foo (5, 5)


sorry for the confusion

Author:  DifinityRJ [ Mon Jan 08, 2007 9:11 pm ]
Post subject:  Re: My take on Mario

Here is if Mario hits goomba, gy1 being goomba's y position and gx1 being his x position, and "x" being mario's x position, and "y" being Mario's y position.
code:

 if y - 5 > gy1 and Math.Distance (x, y, gx1, gy1) <18  then
            check := 1
            up := true
            y := y - 8
            Mariograv := -0.1
            goombadeath := true
end if

Here is if goomba hits mario
code:

if Math.Distance (x, y, gx1, gy1) < 10 and big = false and donthit = false then
            left := false
            right := false
            check := 0
            last := 0
            Pic.Draw (dead, x, y, picMerge)
            Mariodead := true
end if

This is probably inefficient, but i dont know of any better way.

Author:  Clayton [ Mon Jan 08, 2007 9:16 pm ]
Post subject:  Re: My take on Mario

even better, change that into a function:

Turing:

function check_collision (x1, y1, x2, y2, distance : int) : boolean
    result Math.Distance (x1, y1, x2, y2) < distance
end check_collision


then you can simply call that function in an if statement, and if it's true, change your variable accordingly, or even better, call a procedure to do it for you.

Author:  CodeMonkey2000 [ Mon Jan 08, 2007 9:20 pm ]
Post subject:  Re: My take on Mario

shouldnt it be:
Turing:

function check_collision (x1, y1, x2, y2, distance : int) : boolean
    if Math.Distance (x1, y1, x2, y2) < distance then
           result true
     else
          result false
     end if
end check_collision

Author:  Clayton [ Mon Jan 08, 2007 9:29 pm ]
Post subject:  Re: My take on Mario

mine is perfectly legal. In the if statement, an expression has to return a boolean (true or false). Seeing as my function is returning a boolean, we can do away with the if and just return the boolean that would otherwise show up in the if (this only works when there are only two options based on one condition though).

EDIT:

We can work your function down to (basically):

Turing:

function check_collision (x1, y1, x2, y2, distance : int) : boolean
    if true then
        result true
    else
        result false
    end if
end check_collision


This allows us to do something like I did.


: