Pen Collision

Epic428

  • Posts: 1118
Could you specify on what you mean by the collision bounds need tweaking?

What I meant by tweaking is that it doesn't appear the bounds accurately represent what is being drawn on the screen. There were some gaps in my drawing where I felt that I should have been able to move through, but for whatever reason, I was unable to.

Perhaps if you added debug drawing to the game, you could test this out better to see what it looks like, and perhaps get a better idea of how to fix the bounds.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

brantsmith

  • Posts: 151
.....really? Did you modify it at all?

I ask because I tried Greg's solution and it ran fine until you added too many points. Then it slooooowwwweeedddd down.
With your little tech demo, I can draw much much more to the screen before I even notice a performance hit.

The only thing that I changed was that instead of filling a certain pixel. (fill pixel x: y:) I used the (fill rectangle at x: y: with w: h:). Hope this helps.
Coding is Awesome.
Stencyl is Better.

Jesse

  • Posts: 102
Looking good! This may prove to be very useful for Quaintbrush, thank you! :)

brantsmith

  • Posts: 151
Looking good! This may prove to be very useful for Quaintbrush, thank you! :)

In my next demo, I will be showing how this can be used for that sort of game. I will also be putting the demo on stencylforge.
Coding is Awesome.
Stencyl is Better.

brantsmith

  • Posts: 151
Well, I hope this technique is helpful.
Coding is Awesome.
Stencyl is Better.

Rob

  • *
  • Posts: 1268
Brant, nice stuff, how do I draw multiple lines in your game? Right now, they are continuous as one line.
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title

Epic428

  • Posts: 1118
Really nice brant! however I am now seeing a major drop in performance, I am getting like 20 - 30 FPS
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

brantsmith

  • Posts: 151
Really nice brant! however I am now seeing a major drop in performance, I am getting like 20 - 30 FPS


Ah. Actually I was trying to make the lines draw nicer, but i guess it drops the performance. (to Rob): actually, That is something that i tried to get working, but just could not figure out how to do it.
Coding is Awesome.
Stencyl is Better.

Mbr

  • Posts: 11
How do you make it so that when it touches the color black, it sends a message to a behavior to die?

brantsmith

  • Posts: 151
Just use the variable DEAD instead of can move. You would put:
Code: [Select]
if (pixel color = 4278190080)| set DEAD to true| else |set DEAD to false| 4278190080 is the color for black. Than you can use the variable DEAD? to see if your should kill the actor.
Coding is Awesome.
Stencyl is Better.

Mbr

  • Posts: 11

Mbr

  • Posts: 11
Wait, what do I put in the parenthesis next to getX and getY?

brantsmith

  • Posts: 151
Wait, what do I put in the parenthesis next to getX and getY?

Ok. So the idea of this method is that you are checking a pixel at a certain x and y coordinate. So instead of actor.x and actor.y you could put in a x and y coordinate. But that is not what you want. you want to check if the actor is touching black. So, logically, you would put in actor.x (the x of the actor) and actor.Y (the y of the actor). But this does not work. Let me explain. When you put in actor.x and .y you are getting the pixel at the upper left corner of the actor. So it is actually checking what color the pixel at the upper left corner of the actor is. Not the area around it. So what we need to do is put the pixel checker at a spot off of the actor. This all depends on where you need to be checking. lets say that you are not picky where it is. what we can do is place the pixel checker one pixel off of the upper left corner of the actor. You would do this by putting:
Code: [Select]
actor.X - 1, actor.Y ( what this does is sets the x to the x of the actor - 1) This will check the pixel right beside the upper left corner of the actor. this may work good for you. But if you are going to need to put the pixel checker on the bottom of the actor, (say you want to check if the bottom of your actor is touching black.) or on the left side, You will need to do a little more in depth. If this is the case, please PM me and we can work through doing that. Hope this helps.

« Last Edit: June 23, 2011, 02:19:27 pm by brantsmith »
Coding is Awesome.
Stencyl is Better.

thebangzats

  • Posts: 4
Does the color detection work if the color is on the background?

Am currently working on a game involving hiding in the dark, and when you hit a white spotlight for example, you are seen. I would like the lights to instead be an animated background so I can make complicated patterns without having to make them as actors.

Also would color detection work if say, instead of that box you used in the example, a human sprite with a more complicated walk cycle?

Thanks in advance.

brantsmith

  • Posts: 151
Does the color detection work if the color is on the background?

Am currently working on a game involving hiding in the dark, and when you hit a white spotlight for example, you are seen. I would like the lights to instead be an animated background so I can make complicated patterns without having to make them as actors.

Also would color detection work if say, instead of that box you used in the example, a human sprite with a more complicated walk cycle?

Thanks in advance.

Really quickly. I made a mistake. actor.X and actor.Y refer to the upper most left spot on the actor.

Ok, so the pixel detector picks up the pixel color you see. So it does not matter what the object that it is detecting is. It does not deal with stencyl. It deals with the actual pixels on the screen. So if ANYTHING is white on the screen, it will signal.  #2 You will have to place the pixel checker at a place where the actor will not be interfering with. So, say you put it to
Code: [Select]
actor.X - 1, actor.Y That will always place the pixel checker one pixel away from the left corner. So no matter what your actor does, it will always be one pixel off of the actor. But, in your case you might want to put a couple of checker. (you might want to put one in front of the actor to check if the actor is entering a white spotlight.) that is when you will have to be watching out for that kind of stuff. And you will have to put the pixel checker in relation to the actor. (so say you want the checker to be in front of the actor. and say your actor is 30 pixels wide. You will have to put
Code: [Select]
actor.X + 31, actor.Y But the tricky part is finding out how many pixels your actor is, and what to write in the code, and if or if not the actors position will change and interfere with the pixel checker.) also in this case you may want to add 2 points/checkers. One on the right side, and one on the left. (the left one will be easy. Just type in
Code: [Select]
actor.X - 1, actor.Y + 5 (actor.X - 1: this will place it one pixel off of the left side of the actor.)(actor.Y + 5: this is just to place the pixel checker a little lower than the top of the actor.) But for placing the right side, it will be harder. You will have to find the width (in pixels) of your actor, and add 1 to that #, what that will do is put the checker one pixel past the furthest right point of your actor. But then you will have to check if your costumes will interfere with the checker.
Coding is Awesome.
Stencyl is Better.