Folleach / GeometryDashAPI

API for Geometry Dash
MIT License
60 stars 8 forks source link

HSV properties for blocks #35

Open whamer100 opened 6 months ago

whamer100 commented 6 months ago

I want to be able to set the hsv attribute of blocks when creating them for levels. I've tried implementing it myself but I can't get it quite right.

What I have identified so far is that GameProperty 43 is the hsv value, 41 means to use hsv on base (I think 42 is to use hsv on detail, havent checked). For whatever reason when I tried implementing this myself, every block's scale (even ones that arent being created by the program) just completely breaks and gets set to 0.20.

Folleach commented 6 months ago

Thank you for request and research!

I've add this feature to Block and basic interface IBlock
Wanted to add to classes with color, but this, unfortunately, will not work until there is a complete mapping id -> class

Released in v0.2.25

Usage

level.Blocks.Add(new Block(216)
{
    PositionX = 30,
    PositionY = 30,
    Hsv = new Hsv()
    {
        Brightness = 0.5f,
        DeltaBrightness = true
    },
    AdditionalHsv = new Hsv()
    {
        Hue = 120,
        Saturation = 0.5f
    }
});

// Pay attention: block with id 1887 has only detail color, but hsv isn't additional
// AdditionalHsv used for detail color only when both color (base and detail) are present in the block
level.Blocks.Add(new Block(1887)
{
    PositionX = 60,
    PositionY = 30,
    Hsv = new Hsv()
    {
        Hue = 60
    }
});

As for your problem, when all the blocks change the scale to 0.20, there is probably an incorrect character written to the level string somewhere.
Geometry Dash is very sensitive to the character in a level.
So one erroneous character in one block can break the entire level completely ¯\_(ツ)_/¯

whamer100 commented 6 months ago

From testing, for whatever reason setting the scale to 5 for the smallest pixel blocks equals a scale of 1 in the editor. I wonder if Rob is cheating here by using the same block code but with different scaling.

whamer100 commented 6 months ago

Got around to testing this and this works! It definitely looks like Rob has specific handling of the scale value for these pixel blocks, as it appears to divide the scale value by 5 no matter what the input is. I also still really wonder what GameProperty 155 is. If I was more knowledgeable on reverse engineering gd I would look into it myself.