completed set_player

This commit is contained in:
Timothy GFO 2023-10-24 01:40:17 -04:00
parent 07a393b9b7
commit 85c21c2ec5
3 changed files with 33 additions and 21 deletions

View file

@ -9,7 +9,7 @@ This includes:
* Every function that spawns something in the level should have intuitive naming and arguments.
* A stable base to improve upon: Every function will lookup in the definitions.py file.
* Be able to generate from scratch a valid mmlv file, as well as modifying a file (valid or not).
* It should also be able to FIX corrupted Mega Man Maker Levels, at least attempt to.
* It should also be able to FIX corrupted Mega Man Maker Levels, at least attempt to. How? Maybe, checking for duplicate keys (hard), checking for incorrect values, checking for invalid coordinates...
## Installation
Dependencies:
@ -29,6 +29,11 @@ If you find a bug, remember to create an issue about it. But don't do it right n
add get functions
add automatic room activation to set_tile
add ability to all functions to accept raw x, y values (the times 16 numbers in mmlv) and raw codes (like "a" instead of "active")
complete set_tile, set_spike, set_ladder
add set_enemy and set_boss
add way to figure out if there's a player (megaman, protoman etc...) in the file
have integrated functions for changing/replacing the blocks that have some code in them with something else.
add verifier for what a block contains, what type of *thing* (the block x, y contains an object, or the block 1, 5 contains an enemy object)
## Contributing
I would like to be the main developer of this project until it has some missing core functions and it reaches beta. After that feel free to leave pull requests for me to check.

View file

@ -125,7 +125,6 @@ def set_values(key, x="", y="", value=""):
else:
Exception("no value specified in set_values. that is ironic.")
#def check_overlap(x,y):
@ -183,9 +182,9 @@ def set_tile(x, y, tilename="mm1cuttile", tile_type="normal", tile_subtype=False
x16 = str(by16[0])
y16 = str(by16[1])
if is_block_used(x, y):
#if is_block_used(x, y):
#this needs a check to see if the coordinates are already taken, and deal with object-tile conflicts accordingly.
opt = get_options()
# opt = get_options()
#WIP
option = 0
error = False
@ -240,16 +239,17 @@ def del_tile(x,y,times_16=False):
y = str(by16[1])
for letter in definitions.block_with_coordinates:
current = f"{letter}{x},{y}
current = f"{letter}{x},{y}"
config.remove_option(section, current)
### should check if there is another "1t" (and maybe "r" and "e" idk) and delete everything on that tile.
def set_player(x, y,player_type="mm",direction="right", allow_duplicates=False):
def set_player(x, y, player_type="mm",direction="right", allow_duplicates=False):
by16 = conv_coordinates_x16(x, y)
x16 = str(by16[0])
y16 = str(by16[1]) #Every function that has something like all this should be a funcion.
if is_block_used(x, y):
#this should check if what is there is a player, if so then only replace the values?
del_tile(x16, y16)
type_lookup = {
@ -259,16 +259,18 @@ def set_player(x, y,player_type="mm",direction="right", allow_duplicates=False):
"r":{"r":"4", "1t":"3","e":"3"}
}
a = "1"
d = "4"
player_dictionary = type_lookup[player_type]
player_dictionary["a"] = "1"
player_dictionary["d"] = "4"
#this should reset after function ends (so remove b from dictionary)
if direction == "left":
player_dictionary["b"] = "-1"
for key in player_dictionary:
value = player_dictionary[key]
full_key = f"{key}{x16},{y16}"
#this is needed because 1t doesn't have coordinate values in the key'
if key == "1t":
full_key = key
config.set(section,full_key, value)

View file

@ -20,18 +20,23 @@ mmlv.read_file()
#print(mmlv.get_block_contents(1,2))
#print(mmlv.is_block_used(1,2))
# n = 1000
# t0 = time.time()
# # for i in range(n): mmlv.get_block_contents(1,2, True)
# for x in range(mmlv.max_x+1):
# for y in range(mmlv.max_y+1):
# if mmlv.is_block_used(x,y):
# print(mmlv.get_block_contents(x, y))
# t1 = time.time()
#
# total_n = t1-t0
# print(total_n)
mmlv.set_player(1,1, player_type="pm")
n = 1000
t0 = time.time()
# for i in range(n): mmlv.get_block_contents(1,2, True)
repeat = 0
for x in range(mmlv.max_x+1):
for y in range(mmlv.max_y+1):
#if mmlv.is_block_used(x,y):
repeat = repeat + 1
print(x,y)
mmlv.set_tile(x, y)
#print(mmlv.get_block_contents(x, y))
t1 = time.time()
total_n = t1-t0
print(total_n)
print(repeat)
mmlv.write_changes("sample.mmlv")
#del_tile(1,1)