Skip to main content

Lib for work this Geometry Dash levels

Project description

gddecoder

Lib for work this Geometry Dash levels

Start

from gddecoder import *

levels = LocalLevels()

If you need to work with a save file that is not in the standard path

levels = LocalLevels("path/to/file/CCLocalLevels.dat")

LocalLevels is list of levels, to get the level, use the levels.get_level() method or standard list syntax levels[n].

level1 = levels.get_level(10)
level2 = levels.get_level("first level")
level3 = level[10]

levels[n] don't support levels names, level["first level"].

Change levels

Level is dict. To refer to a key in a level, you can use the name of the key that matches the name of the key in the game's save file, or use the LevelSettings enum.

level["k2"] = "test level"
level[LevelSettings.objects_count] = 800

Some programs

Print names of all levels:

from  gddecoder import *


levels = LocalLevels()

for lvl in levels:
    print(lvl[LevelSettings.name])

Counting the total number of jumps in levels:

from gddecoder import *


levels = LocalLevels()

jumps = 0

for lvl in levels:

    # test because the level may not have jumps
    if LevelSettings.jumps in lvl:
        jumps += lvl[LevelSettings.jumps]

print(jumps)

Editor

Level has method get_editor, it return Editor object.

editor = level.get_editor()

Editor object has attribute blocks and colors. Other properties are stored as in a dictionary. Use EditorSettings enum or game key.

# set 2 player mode
editor[EditorSettings.two_player_mode] = True
# get 20 block in level
blocks = editor.blocks[19]
# get bg Color
color_bg = editor.colors[1000]

Blocks

Blocks are also dictionaries. Use BlockSettings enum.

block = editor.blocks[9]
block[BlockSettings.x] = 30
block[BlockSettings.y] = 15

Add block

editor.blocks.add(Block(
    {
        BlockSettings.id: 1,
        BlockSettings.x: 15,
        BlockSettings.y: 15,
    }
))

Block duplication

editor.blocks.add(Block(
    editor.blocks[9]
))

Set groups

Groups is set.

block = editor.blocks[9]
block[BlockSettings.groups] = Groups([1, 2, 10])
block[BlockSettings.groups].add(14)
block[BlockSettings.groups].pop(10)

Colors

The block stores only the color channel of the block as an int. To change a color, you need to change the corresponding color in editor.colors and then assign it to the block.

Save

Save to standart path:

level.set_editor(editor)
levels.save()

For other path:

level.set_editor(editor)
levels.save("other/path/file.dat")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gddecoder-1.1.0.tar.gz (11.2 kB view details)

Uploaded Source

File details

Details for the file gddecoder-1.1.0.tar.gz.

File metadata

  • Download URL: gddecoder-1.1.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for gddecoder-1.1.0.tar.gz
Algorithm Hash digest
SHA256 af83cc4b037ea276e52bd7b75347401ead28e625ffc1faec9c54bbe68c540639
MD5 4f024b3bfe4982996fe32a3ce7db771d
BLAKE2b-256 ce593847af7120b17832c55c3382d16d696a7732b8df8c41415502a6d2466055

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page