Draw a circle around the player using Canvas [SOLVED]

Non-platform specific questions.

Draw a circle around the player using Canvas [SOLVED]

Postby Hblade » Tue Mar 20, 2012 6:44 pm

Hi, I want to make a room in my game where it's pitch black and you have a light that surrounds the player (This is done by a canvas covering the screen and its drawing solid black, but then uses some.. well, the question of this topic :P) The plan is, the circle will start bright in the center (about 32x32 with complete opacity), then get darker as it increases in distance. Any idea how to do this?

Example:
example.png



EDIT:
Solved and working amazingly :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: Draw a circle around the player using Canvas

Postby Hblade » Tue Mar 20, 2012 6:45 pm

Hblade wrote:Hi, I want to make a room in my game where it's pitch black and you have a light that surrounds the player (This is done by a canvas covering the screen and its drawing solid black, but then uses some.. well, the question of this topic :P) The plan is, the circle will start bright in the center (about 32x32 with complete opacity), then get darker as it increases in distance. Any idea how to do this?

Example:
example.png




If this can't be done I have another plan.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby jimmynewguy » Wed Mar 21, 2012 4:20 pm

Doing this with the canvas would be really slow I think. You might be better off making a sprite that is a light (like you have in your example) with a large black background and have it follower the player, if you get what I mean.

EDIT: Saw your edit. What did you end up doing?
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1138
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby Hblade » Wed Mar 21, 2012 4:38 pm

It was frightenly slow, so I used a gigantic image and placed it correctly. which was what you said :P Check out the game demos, Sky made a nice canvas effect for lighting. It's very interesting to say the least. I love it. It's in my realime lighting thingy.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby RippeR7420 » Thu Mar 22, 2012 7:22 pm

I ended up making an Actor called "Darkness", and changed the transparency a bit.

like this :)

Image

It doesn't look as good as yours does though haha :D
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob http://game-editor.com/forum/viewtopic.php?f=4&t=12519

-StickMcGee: Blast to the Future - No forum for this project as of yet
User avatar
RippeR7420
 
Posts: 357
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 18 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby Hblade » Thu Mar 22, 2012 7:55 pm

You cna use mine if you want :)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby RippeR7420 » Thu Mar 22, 2012 7:56 pm

Awesome deal! thank you Hblade!
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob http://game-editor.com/forum/viewtopic.php?f=4&t=12519

-StickMcGee: Blast to the Future - No forum for this project as of yet
User avatar
RippeR7420
 
Posts: 357
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 18 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby Hblade » Thu Mar 22, 2012 7:59 pm

Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby Hblade » Thu Mar 22, 2012 8:00 pm

it might be too large, if so I can design you one.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby RippeR7420 » Fri Mar 23, 2012 6:33 am

Could you make me one in Iphone res. (480x320(Rotated left))?
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob http://game-editor.com/forum/viewtopic.php?f=4&t=12519

-StickMcGee: Blast to the Future - No forum for this project as of yet
User avatar
RippeR7420
 
Posts: 357
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 18 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby Hblade » Fri Mar 23, 2012 1:34 pm

The thing is ripper, it has to be like 2.5 times larger than the original res, otherwise the black-area will vanish if the player is in a corner (Or the edge of the screen if your at the last part of the map) :P

So, whats the max resolution image an Iphone can handle?
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby Game A Gogo » Fri Mar 23, 2012 3:10 pm

I think it's 2048x2048, or 1024x1024, I forgot. Probably the smaller one
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3464
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Draw a circle around the player using Canvas [SOLVED]

Postby Hblade » Fri Mar 23, 2012 3:30 pm

Okay here ya go :3 grr uploader glitching out again DX so I have to use this, here :3
http://img835.imageshack.us/img835/4527/lightfl.png

Image
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4379
Joined: Fri Dec 08, 2006 11:14 pm
Score: 169 Give a positive score


Return to General

Who is online

Users browsing this forum: Google [Bot] and 1 guest