DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   Mario clone (http://www.daniweb.com/forums/thread160688.html)

tomtetlaw Dec 4th, 2008 5:59 am
Mario clone
 
Hi all!
Im making a mario clone, and i was wondering how to write the jump function in the Mario class, any help would be good, im using PyGame by the way. heres my code so far:
#usr/bin/env python
import sys
import os

import pygame
from pygame.locals import *

class Mario():
    def __init__(self):
        self.image, self.rect = pygame.load_image('mario.png')
        self.health = 1
        self.alive = 1
    def walkRight():
        self.move()
    def walkLeft():
        self.-move()
    def jump():
THanks

Freaky_Chris Dec 4th, 2008 6:29 am
Re: Mario clone
 
Well what idea's do you have for writing a jump function. I guess you would have to think about a couple of things, What exactly is your motion path when you jump, how the direction of movement before hand effects the mothion path of the jump. Also you would need a method of checking whether or not you have landed/collided with another object.

Chris

tomtetlaw Dec 5th, 2008 9:32 pm
Re: Mario clone
 
The motion path would be like 70 or so pixels upwards, The direction of movement would be decided on the deriction that mario is moving, and the method for detecting collisions would be something like pygame.colide_get_rect() i think thats the name of that function.

Freaky_Chris Dec 6th, 2008 3:11 am
Re: Mario clone
 
So your set and know what you are doing. Trying coding something then coming back with specific problems

Chris

tomtetlaw Dec 6th, 2008 3:14 am
Re: Mario clone
 
Ok, will do :)


All times are GMT -4. The time now is 9:43 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC