Computer Science Canada Whatdotcolor collision help |
| Author: | sierius [ Sun Nov 16, 2008 2:18 pm ] | ||
| Post subject: | Whatdotcolor collision help | ||
This is the code of a platformer game I was trying to create. I first approached by trying to input if any point on the base posx ... poxs + 20 and and posy -1 was the leveled black line then don't move. but I have 4 platforms so that would be a hassle. I looked a little into whatdotcolor collision and found it should be able to help me. But what I no understand is how to make it function. I have set a boolean variable called jumponly so you can only jump once again if you are on a platform or the 'base' However, the square never halted when its above the platform, instead it falls down. If anyone could tell me what I am doing wrong it would be appreciated ^^ |
|||
| Author: | DanielG [ Sun Nov 16, 2008 2:30 pm ] |
| Post subject: | RE:Whatdotcolor collision help |
doesn't run, missing drawbg and level_tut_i procs |
|
| Author: | isaiahk9 [ Sun Nov 16, 2008 2:43 pm ] |
| Post subject: | RE:Whatdotcolor collision help |
@ DanielG : Just comment it out. Although, you don't actually need to see the program running to help sierius. @ sierius : Before you draw your square in your loop, you have to go something ike this : If View.WhatDotColor (posx, posy ) = black then posy += 5 End If Off the top of my head, that's it. PS : I'm pretty sure most of that code can be found in that gravity tutorial in the tutorial section. . . |
|
| Author: | TheGuardian001 [ Sun Nov 16, 2008 2:48 pm ] |
| Post subject: | Re: Whatdotcolor collision help |
major edit here: ok, having looked over your code again, I know why it doesn't work. at the start of the loop you clear the screen with cls. then check for collisions. then draw the boxes. since you cleared the screen, it is now completely white. you then check if you've hit a black pixel, which you haven't, because the screen is white, then you draw. simply switching the order of these things should make it work properly. |
|
| Author: | isaiahk9 [ Sun Nov 16, 2008 3:39 pm ] |
| Post subject: | RE:Whatdotcolor collision help |
TheGaurdian001 makes an excellent point : your amount of pixels you increase in height should equal your gravity decreasing your pixels. But that wasn't his excellent point. it is that : View.WhatDotColor really is not good. I spent hours on my project last year trying to fix failing View.WhatDotColor, and in the end the best choice was to "hard-code" the platforms (make it so that if the user's position is where the platform is, their y variable/x variable increases/decreases). Saving yourself the trouble, in my mind would be avoiding View.WhatDotColor. |
|