Help me please

Posts for SD2D Ideas, Discussion and Bugs!

Play it here https://www.gevanni.com:3000/

Help me please

Postby daft punk 777 » 19 March 2021, 11:39

So, i noob in js, and i did smthng like working server.
i made 10240 energy crystal and i want to color it.
if ( v > 40 )
{
if ( v === 10240 )
return 'hue-rotate(200deg) brightness(3) drop-shadow(0px 0px 7px #1bff00)'; <---- this is it
else
if ( v === 5120 )
return 'hue-rotate(200deg) brightness(1.3) drop-shadow(0px 0px 7px #FFFFAA)';
else
if ( v === 2560 )
return 'hue-rotate(170deg) brightness(0.8) contrast(2)';
else
return 'hue-rotate('+( v - 40 )+'deg)';
}
And i colored it with brightness. But i want to make it for example bright green, or even custom texture color.
If i put smthng like color(#htmlcolorhere) or color="green", color("green"), color="#htmlcolor" its just basic cyan crystal. I droped my texture in assets but idk how to load it only on this crystal, and when i tryed to do that i got only crashed server... I really dont know what else i can do. Help please
User avatar
daft punk 777
Falkok [250]
 
Posts: 295
Joined: 22 December 2016, 11:15

Re: Help me please

Postby Eric Gurt » 20 March 2021, 02:11

It works by these rules:
https://developer.mozilla.org/ru/docs/Web/CSS/filter

You can do more live tests by starting server, opening game in webkit browser (like Chrome or Edge), looking at this crystal, then:
1. Press Ctrl + Shift + I
2. Switch to "Console" tab
3. Click at last line where you can enter code or commands (next to > symbol)
4. Type in: sdWorld.GetCrystalHue
5. Press Enter
6. Click on any text that appeared here (whitespaces don't count)
7. It will open your file and specifically method sdWorld.GetCrystalHue. Here you can live edit your code and pressing Ctrl+S will reflect changes on screen. These changes won't be saved to disk unless you copy them into your code editing software (IDE) and save them there.

So about CSS filter rules - they are space separated and support very limited set of effects, but these include enough variety for crystal color change. Star Defenders 2D caches each image with each filtering so it should be fine to have any complexity of them.
Work it harder
Make it better
Do it faster
Makes us stronger
More than ever hour
After our work is never over.
User avatar
Eric Gurt
PB2 Developer
 
Posts: 409
Joined: 14 July 2013, 16:46
Location: dn.ua

Re: Help me please

Postby daft punk 777 » 20 March 2021, 03:50

Thanks a lot! It works now!
I will write again if i need help)
User avatar
daft punk 777
Falkok [250]
 
Posts: 295
Joined: 22 December 2016, 11:15


Return to Star Defenders

Who is online

Users browsing this forum: No registered users