I Need Mario To Lose A Life, But I Can't Figure It Out!
Author |
Message |
master-awesome
|
Posted: Tue Dec 23, 2014 3:36 pm Post subject: I Need Mario To Lose A Life, But I Can't Figure It Out! |
|
|
So I'm basically trying to develop a Mario game, but I'm starting with Mario losing a life to Dark Mario. Basically, I want Dark Mario to touch Mario and a life is lost from that part. Here's what I've done so far....
Description: |
|
Download |
Filename: |
Game Test.zip |
Filesize: |
8.62 MB |
Downloaded: |
83 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Tue Dec 23, 2014 3:45 pm Post subject: RE:I Need Mario To Lose A Life, But I Can\'t Figure It Out! |
|
|
Step 1: Detect if Mario gets hit
Step 2: Decrement the life variable.
I think you probably know how to decrement a variable, so you're probably having trouble with step 1. If that's the case, look up collision detection.
|
|
|
|
|
|
master-awesome
|
Posted: Tue Dec 23, 2014 4:28 pm Post subject: Re: I Need Mario To Lose A Life, But I Can't Figure It Out! |
|
|
I tried your thing out, but it is still giving me the same problem. Could you tell me what I'm doing wrong in my code?
P.S. I moved the lives down to the if statements at the bottom. HELP!
Description: |
|
Download |
Filename: |
Game Test.zip |
Filesize: |
8.62 MB |
Downloaded: |
73 Time(s) |
|
|
|
|
|
|
Insectoid
|
Posted: Tue Dec 23, 2014 5:06 pm Post subject: RE:I Need Mario To Lose A Life, But I Can\'t Figure It Out! |
|
|
I don't think you really looked through a collision detection tutorial, because this line makes no sense at all: code: | if dx <= x and dx >= x and x <= y and x >= y and dx <= y and dx >= y then |
Read that line. Try to come up with a situation where that returns true, and what the screen would look like in that situation.
Find a collision detection tutorial, and actually read it and re-read it until you understand what's going on. Write a simple program that prints 'bleh' if two rectangles collide. Keep working at it until you know how to apply it to your program in a way that makes sense.
There are shortcuts in math, or physics, or English. You can get away with not actually knowing your stuff. That doesn't work in computer programming. You can only write working programs if you understand how and why the code you're writing works (for now anyway).
|
|
|
|
|
|
master-awesome
|
Posted: Tue Dec 23, 2014 6:45 pm Post subject: Re: I Need Mario To Lose A Life, But I Can't Figure It Out! |
|
|
Okay thanks! The code is finally working! My only mistake was not giving the two characters a y variable.
Description: |
|
Download |
Filename: |
Game Test.zip |
Filesize: |
8.62 MB |
Downloaded: |
91 Time(s) |
|
|
|
|
|
|
|
|