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

Username:   Password: 
 RegisterRegister   
 I Need Mario To Lose A Life, But I Can't Figure It Out!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
master-awesome




PostPosted: 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....


Game Test.zip
 Description:

Download
 Filename:  Game Test.zip
 Filesize:  8.62 MB
 Downloaded:  83 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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




PostPosted: 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!



Game Test.zip
 Description:

Download
 Filename:  Game Test.zip
 Filesize:  8.62 MB
 Downloaded:  73 Time(s)

Insectoid




PostPosted: 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




PostPosted: 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.


Game Test.zip
 Description:

Download
 Filename:  Game Test.zip
 Filesize:  8.62 MB
 Downloaded:  91 Time(s)

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  [ 5 Posts ]
Jump to:   


Style:  
Search: