using canvas

Non-platform specific questions.

using canvas

Postby BlarghNRawr » Sat Jul 26, 2008 7:06 am

can i make an actor colide only with the line drawn on a canvas to have a physical response?
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: using canvas

Postby feral » Sat Jul 26, 2008 8:03 am

yes you can :D

the important thing to remember ,is to erase your canvas first ,otherwise the collision will occur with the entire canvas rather then what is draw on it ( as a canvas is only semi transparent when created until it is erased)

eg: in create actor (canvas)

erase(0, 0, 0, 1);

also your line should be wider then your motion otherwise you may still go through it
eg: if your motion is x=x+4, or xvelocity=4 then the line should be at least 4 pixels wide otherwise you may "skip" over it.

if your line needs to thinner you can use collsionfree to check for the line before you move.

hope that helps
:D
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: using canvas

Postby speckford123 » Tue Jul 29, 2008 12:11 pm

feral wrote:yes you can :D

the important thing to remember ,is to erase your canvas first ,otherwise the collision will occur with the entire canvas rather then what is draw on it ( as a canvas is only semi transparent when created until it is erased)

eg: in create actor (canvas)

erase(0, 0, 0, 1);

also your line should be wider then your motion otherwise you may still go through it
eg: if your motion is x=x+4, or xvelocity=4 then the line should be at least 4 pixels wide otherwise you may "skip" over it.

if your line needs to thinner you can use collsionfree to check for the line before you move.

hope that helps
:D


WOAH, WOAH, WOAH! woah................woah...........
for the past 2 years people in the forum have been telling me collisions with the canvas lines was impossible, when did this change all of a sudden?
unless EVERYONE forgot to erase the canvas first..........

well then, now i'm inspired.............
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

Re: using canvas

Postby BlarghNRawr » Tue Jul 29, 2008 10:33 pm

oooh, this could be useful, now i can remake that old game of mine...

PAPERWARS EXTREME!!!!! MUAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA :twisted: :twisted: :twisted:
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: using canvas

Postby feral » Wed Jul 30, 2008 3:57 am

here is a simple demo of canvas lines and collisions
Just remember to erase canvas first ..



try to get close to the blue lines - cursor keys to move

canvasdraw.zip
(17.03 KiB) Downloaded 94 times


ps: if anyone remembers QIX - this is how to do it..
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: using canvas

Postby BlarghNRawr » Wed Jul 30, 2008 11:09 pm

im not allowed 2 download ne thing so...
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: using canvas

Postby feral » Wed Jul 30, 2008 11:52 pm

blarghNRawr wrote:im not allowed 2 download ne thing so...


ok ... for a simple demo..

create a canvas actor about half the size of the screen and put this code in the draw actor script

Code: Select all
int top;
int base;
top=rand(200);
base=rand(200);
erase(0,0,0,1);  // this is NEEDED see notes above
setpen(0, 0, 255, 0, 2);
moveto(top,0);
lineto(0,base);


it will draw a random flickering blue line. now simply create another normal actor and move it about and test collisions with the canvas.. and you will see how to use canvas drawn collisions
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: using canvas

Postby BlarghNRawr » Sun Aug 03, 2008 8:49 pm

mkay, i will try it when i get home
(im using an ipod touch now :D )
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron