Powered by Invision Power Board

 
    Reply to this topicStart new topicStart Poll

> Alpha levels help in GM7 PRO
United States
Project_MK
Posted: Oct 6 2009, 08:59 PM
Quote Post


Wayward Vagabond
[*][*][*][*]

Group Icon
Group: Members
Posts: 1763
Member No.: 3159
Joined: 7-January 07

Status: (0d) [--]


So I have this script right;
CODE
obj_gradient1.image_alpha=-distance_to_object(obj_player)+1
if obj_gradient1.image_alpha>1 obj_gradient1.image_alpha=1

and like, it doesn't work.
In case you can't tell I'm trying to make obj_gradient1 to get less transparent the closer you are to it. Probably doing this really wrong, kind of a novice here!
Help is appreciated!


--------------------

user posted image
Click banner for reference.
PMEmail PosterAOLYahooMSN
Top
United States
OniLink10
Posted: Oct 6 2009, 09:03 PM
Quote Post


C++ Programmer, Unofficial Physicist, and Unofficial Chemist
[*][*]

Group Icon
Group: Members
Posts: 3920
Member No.: 4907
Joined: 19-February 08

Status: (0d) [--]


Making it less transparent the closer you are to it?

Here's some Pseudo-Code:
Set Alpha to (MaximumDistance-Distance)/MaximumDistance

Actually, I have to check something about Game Maker, so that Division may change a little bit.

EDIT: Alright, the code should be good. I wasn't sure whether GM uses 255 or 1 for Completely Opaque.

This post has been edited by OniLink10 on Oct 6 2009, 09:04 PM


--------------------
QUOTE (Xgoff @ Sep 10 2009 @ 06:11 PM)
did you try hello's engine

make sure to not ****ing change anything before using it!
PMEmail PosterUsers WebsiteYahoo
Top
United States
Project_MK
Posted: Oct 6 2009, 09:23 PM
Quote Post


Wayward Vagabond
[*][*][*][*]

Group Icon
Group: Members
Posts: 1763
Member No.: 3159
Joined: 7-January 07

Status: (0d) [--]


QUOTE (OniLink10 @ Oct 6 2009, 08:03 PM)
Making it less transparent the closer you are to it?

Here's some Pseudo-Code:
Set Alpha to (MaximumDistance-Distance)/MaximumDistance

Actually, I have to check something about Game Maker, so that Division may change a little bit.

EDIT: Alright, the code should be good. I wasn't sure whether GM uses 255 or 1 for Completely Opaque.

I'm using your code but it's kind of confusing me... I now have it set to;
CODE
obj_gradient1.image_alpha=(distance_to_object(obj_player)-20)/500
if obj_gradient1.image_alpha>1 obj_gradient1.image_alpha=1

I also tried it replacing 500 with distance_to_object(obj_player), but that didn't work either.


--------------------

user posted image
Click banner for reference.
PMEmail PosterAOLYahooMSN
Top
United States
OniLink10
Posted: Oct 6 2009, 09:47 PM
Quote Post


C++ Programmer, Unofficial Physicist, and Unofficial Chemist
[*][*]

Group Icon
Group: Members
Posts: 3920
Member No.: 4907
Joined: 19-February 08

Status: (0d) [--]


QUOTE (Project_MK @ Oct 6 2009, 07:23 PM)
I'm using your code but it's kind of confusing me... I now have it set to;
CODE
obj_gradient1.image_alpha=(distance_to_object(obj_player)-20)/500
if obj_gradient1.image_alpha>1 obj_gradient1.image_alpha=1

I also tried it replacing 500 with distance_to_object(obj_player), but that didn't work either.

maxdist = 500; // This Variable tells the distance at which the Gradient will be fully invisible. If the Player is any farther than this, it will also be invisible.
obj_gradient1.image_alpha = (maxdist-distance_to_object(obj_player))/maxdist;
That will make sure it is not set to more than one.

Also, when you say it "doesn't work", do you mean the Gradient stays invisible, or fully visible?

BTW, if you take a class like Physics or Chemistry, this is a simple modification of the Percent Error Formula. wink.gif

This post has been edited by OniLink10 on Oct 6 2009, 09:49 PM


--------------------
QUOTE (Xgoff @ Sep 10 2009 @ 06:11 PM)
did you try hello's engine

make sure to not ****ing change anything before using it!
PMEmail PosterUsers WebsiteYahoo
Top
United States
YoManRuLz
Posted: Oct 7 2009, 06:16 PM
Quote Post


sit down, it's just me


Group Icon
Group: Members
Posts: 152
Member No.: 6502
Joined: 6-September 09

Status: (0d) [--]


if image_alpha is 1 or greater, it will be fully visible
so image_alpha=0.5 will make the object half visible
irony: your original code made the object totally visible no matter what


--------------------
PMEmail Poster
Top
United States
Project_MK
Posted: Oct 7 2009, 10:43 PM
Quote Post


Wayward Vagabond
[*][*][*][*]

Group Icon
Group: Members
Posts: 1763
Member No.: 3159
Joined: 7-January 07

Status: (0d) [--]


QUOTE (YoManRuLz @ Oct 7 2009, 05:16 PM)
if image_alpha is 1 or greater, it will be fully visible
so image_alpha=0.5 will make the object half visible
irony: your original code made the object totally visible no matter what

hurr that's why I asked for help

but OniLink, your code worked with a bit of tweaking. Thanks dood.


--------------------

user posted image
Click banner for reference.
PMEmail PosterAOLYahooMSN
Top
United States
OniLink10
Posted: Oct 7 2009, 11:06 PM
Quote Post


C++ Programmer, Unofficial Physicist, and Unofficial Chemist
[*][*]

Group Icon
Group: Members
Posts: 3920
Member No.: 4907
Joined: 19-February 08

Status: (0d) [--]


QUOTE (Project_MK @ Oct 7 2009, 08:43 PM)
hurr that's why I asked for help

but OniLink, your code worked with a bit of tweaking. Thanks dood.

You are very welcome!


--------------------
QUOTE (Xgoff @ Sep 10 2009 @ 06:11 PM)
did you try hello's engine

make sure to not ****ing change anything before using it!
PMEmail PosterUsers WebsiteYahoo
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

  Topic Options Topic Options Reply to this topicStart new topicStart Poll

 




[ Script Execution time: 0.0423 ]   [ 13 queries used ]   [ GZIP Enabled ]   [ Server Load: 1.10 ]