|
Post by MBitt on Dec 29, 2003 10:17:28 GMT -5
I found this script on the web, had no authors name only it was created 6/13/03. It is very good but it slows the game down alot. Can this be fixed? script: scr_shadow
{ var temp_x, X, temp_y, Y, temp_color; temp_color = brush_color; brush_color = c_black; for (temp_x = bbox_left; temp_x <= bbox_right; temp_x += 1;) for (temp_y = bbox_top; temp_y <= bbox_bottom; temp_y += 1;) { X = temp_x + ((-(temp_y-y) + bbox_bottom-y))*1; Y = temp_y; if (position_meeting(temp_x,temp_y,self)) draw_pixel(X,Y); } brush_color = temp_color; } object: draw { scr_shadow(); draw_sprite(sprite_index,-1,x,y); } #nosmileys#nosmileys
|
|
|
Post by IsmAvatar on Dec 29, 2003 16:51:00 GMT -5
below the posting box there is the "Check this if you'll be adding code (or don't like smileys)." checkbox.
I've done it for you.
|
|
|
Post by MBitt on Jan 1, 2004 12:18:40 GMT -5
OK it appears that screen redrawing can not be accelerated, what if this code were used as a utility program. Make a rendering program that you inserted your sprite then dump your screen into a different BMP file each sprite frame. Then reconstruct your sprite with the new shadow.
|
|
|
Post by IsmAvatar on Jan 1, 2004 16:39:58 GMT -5
No idea what you're talking about, but I shrunk down the script a bit. This may speed up game play, but only by a fraction of a frame every second...
script: scr_shadow
_color = brush_color brush_color = c_black for (_x = bbox_left; _x <= bbox_right; _x += 1) for (_y = bbox_top; _y <= bbox_bottom; _y += 1) { X = _x + (-(_y-y) + bbox_bottom-y) Y = _y; if position_meeting(_x,_y,self) draw_pixel(X,Y) } brush_color = _color object: drawscr_shadow() draw_sprite(sprite_index,-1,x,y)
the reason for the slowdown is because of "draw_pixel(X,Y)" drawing a bunch of pixels becomes considerably slow. you could try creating particles instead, but that would be a bit too advanced...
best bets: make a second sprite... much faster.
|
|
|
Post by MBitt on Jan 2, 2004 0:05:23 GMT -5
Do you mean upload the same sprite again, paint it black and attach it to the first sprite at an angle to simulate the shadow effect? Not a bad idea. Thanks.
|
|
|
Post by IsmAvatar on Jan 2, 2004 1:06:38 GMT -5
erm, that wasn't sarcasm, was it? can't tell on the internet.
yeah, that's the method i'd normally use.
|
|
|
Post by MBitt on Jan 2, 2004 8:10:53 GMT -5
I have never used two sprites together like that before. Learn new things everyday. I guess I could just use a little black shadow sprite instead of each individual sprite being reproduced and darkened. Would save space.
|
|
|
Post by Flashback on Jun 26, 2004 13:51:49 GMT -5
I can actually make this incredibly fast...
I'll edit with the script later.
EDIT:
//Flashback's shadow script //Designed for a 24x32 sprite - change as needed
pen_color = c_black brush_color = c_black
//you can also change the brush style using brush_style, but it doesn't look terribly good
draw_ellipse(char.x,char.y+25,char.x+24,char.y+36) //change"char" to your character/object's name. also, change the drawing settings for the ellipse, as it needs to be adapted to your sprite's dimensions
//© 2004 to Flashback. All Rights Reserved. If you claim this script as yours, you will be subject to hanging.
This script is designed for a sprite that is 24x32. modify as needed, but please keep the comments in.#nosmileys#nosmileys
|
|
|
Post by IsmAvatar on Jun 26, 2004 16:44:06 GMT -5
draw event of character:
push_graphics_settings() pen_color = c_black brush_color = c_black draw_ellipse(x,y+sprite_height-sprite_height/32,x+sprite_width,y+sprite_height+sprite_height/32) draw_sprite(sprite_index,image_single,x,y) pop_graphics_settings()
allows for any size sprite, draws a circle somewhat proportionate to the character's height. Change the /32 to /16 or something else if you don't think the proportion is right.
This script based off of Flashback's script, but greatly improved by Ism.
Note, that when GM 6 comes out, drawing functions should be much faster, so the first script posted here should work at a fine speed.
|
|
|
Post by Flashback on Jun 26, 2004 17:01:16 GMT -5
wow, thanks for the update ism! Mind if I upload the improved version to my site?
|
|
|
Post by IsmAvatar on Jun 26, 2004 17:30:40 GMT -5
With credit, please.
|
|
|
Post by Flashback on Jun 27, 2004 11:48:53 GMT -5
uploading...
|
|