2020-06-06 18:35:57

Right. You should have gotten everything you needed from post 99. Feel free to ask for clarification, but I really think I explained it accurately enough to make you understand.

2020-06-07 20:49:36

hey all, I didint spammed questions in a while so

what is the best way to make a map cystom? that's, making the player able to walk on difrint platforms
I have a half completed idea in my mind but it cant be done I think because its half completed
useing arrays to hold difrint platforms
but I have no idea how to do this on code, if you give me the logik of such thing I can translate it in to code, I promiss

2020-06-07 23:47:46

When you say "platform", in what way do you mean? Like a free moving game like Zelda, or like a snap like tile based roguelike? Is it a side scroller or top down?

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-06-07 23:58:13

no just topdown, like putting a sand platform at from x 0 to x 100 and from y 10 to y 30, you got the idea

2020-06-08 00:18:14

How you handle the data can have an effect on the kind of response or effect your going for. In a game like Zelda, you can walk fluidly across many tiles in a non-even way, whereas in a roguelike you snap from one tile to the next and a very set way. The difference really is more in how you handle moving the player, not necessarily on how you handle the map data. But anyway, how tile based maps are usually handled is with a simple 2D array, or a list of lists, creating an area with a width and height:

#a 5 by 5 map
area = [[0,0,0,0,0],
        [0,0,0,0,0],
        [0,0,0,0,0],
        [0,0,0,0,0],
        [0,0,0,0,0]]

In the above code we have a 5 by 5 map area. Each element in those lists, in this case a bunch of zeros, symbolically represents objects. 0 in this case means open space, but you could make it so the number 1 means a wall, 2 a torch, 3 a goblin, etc. This is a way of representing things in an abstract sense within a map area. You can go deeper with this using a 3 dimensional array. There are other ways of handling it though that don't necessarily involve grids, if you'd prefer.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2020-06-08 00:31:16

not like that, I ment something like the following
lets asoom I have a function that do what neads to be done to make a new platform, it takes 5 poramitors, minx, maxxx, miny, maxy, tilename
and I do the following
platform(0,10,10,20,"dert")
and then while the player is inside minx,maxx,miny,maxy and they walk they will hear the sound of tilename+".ogg"

2020-06-08 14:07:16 (edited by Meatbag 2020-06-08 14:08:45)

so
is nuitka good with compiling python scripts?
I mean is decompiling with it is as easy as pyinstaller, if not it will be great, I guess?

2020-06-08 15:28:42

If you’re looking for code protection, Cython  is your best bet.

2020-06-09 04:41:22

i use pyinstaller. but it is very symple. you can encript your bite code with a key then it is not easy to retrieve your code.

if you like this post, please thum it up!
if you like to see my projects, feel free to check out my github
if you want to contact me, you can do here by skype. or you can follow me on twitter: @bhanuponguru
discord: bhanu#7882

2020-06-10 02:19:00

arg! TypeError: list indices must be integers or slices, not str, that's no good! so I cant make string lists?

2020-06-10 02:24:03

Lists are arrays. If you want to do what you're calling string lists, use a dict:

x = dict()
x["foo"] = 5

Or:

x = {
    "foo": 5,
    "bar": 12,
    "the_player": player,
}

Iterating (for i in my_dict) gives the keys. Usually people will do:

for k, v in my_dict.items():
    # stuff

SO that they can get both at once (k is the key, v is the value, I wouldn't get into how .items() works, just use it).

My Blog
Twitter: @ajhicks1992

2020-06-10 02:27:29

oh? I didint thot arrays are normily cant be strings..., in bgt we can just do string[]

2020-06-10 02:36:11 (edited by Meatbag 2020-06-10 02:37:44)

ok here is the code
I tryed to make a simple thing to make a map cystom, a very simple one, and I think I got it?
map=[]
def platform(minx,maxx,miny,maxy,minz,maxz,tilename):
    map.append(str(minx)+":"+str(maxx)+":"+str(miny)+":"+str(maxy)+":"+str(minz)+":"+str(maxz)+":"+str(tilename))
def gt(x,y,z):
    mt=""
    for i in map:
        sd=map[i].split(":")
        if len(sd)== 7:
            x1=int(sd[0])
            x2=int(sd[1])
            y1=int(sd[2])
            y2=int(sd[3])
            z1=int(sd[4])
            z2=int(sd[5])
            tile=str(sd[6])
            if x1<=x and x2>=x and y1<=y and y2>=y and z1<=z and z2>=z:
                mt=tile
    return mt
platform(0,10,0,10,0,0,"sand")
print(gt(1,1,0))
the error hapins in this line
        sd=map[i].split(":")

2020-06-10 03:18:26

Well, to be honest, if you have a thing that's made of lists, dicts, ints, floats, and strings only, you can save yourself a lot of trouble and:

import json
print(json.dumps(thing))

And to read/write JSON to a file I believe it's:

with open("file.txt", "w") as f:
    json.dump(obj, f)

And:

with open("file.txt", "r") as f:
    x = json.load(f)

I might be slightly off on the file ones though.  But it will just handle all of this parsing for you.  If you need something human editable that's a little bit harder, you might want to write your own parser, but the JSON dump and dumps functions take 4 or 5 arguments that make it pretty and there's also pyyaml and toml which have almost the same API but write things in a format that's even more friendly to humans.

But to answer your question, you can do lists of strings, but the indexes aren't strings, the values are strings.  I don't know what BGT has, but as far as I know the AngelScript arrays don't have string indices either unless AngelScript did the thing where you combine arrays and dicts, which I don't think it does.  I'm pretty sure you're misunderstanding how arrays work somehow.

But for your code itself, for i in map gives you the elements in the list, so

map[i]

isn't necessary, just use i. If you want i to be the indices you need for i in range(len(map)), but that's the long way around when for i in map is good enough.  Python for loops are not BGT for loops, you're getting the values of the thing being iterated over.  I'm not going to explain further unless there's something more to be said that's not in post 99.

My Blog
Twitter: @ajhicks1992

2020-06-10 03:24:34

thanks! I got it to work by doing:
for i in range(len(map))

2020-06-10 03:33:32

That's fine, but you could have just used i directly instead of making i be an integer and indexing into map yourself.  Until you understand this, you'll keep having these issues, and you'll have an extremely hard time with dicts and sets, where whre range(len(x)) won't work anymore.

My Blog
Twitter: @ajhicks1992

2020-06-10 03:39:39

if the range methid be useless i'll be scrood then I dont really know of an other way

2020-06-10 04:34:25

Please go read post 99. Please. I wrote it for a reason.

2020-06-10 12:48:15 (edited by Meatbag 2020-06-10 12:49:19)

cmon 118, I did  read it again and that how I knoo I should of used range(len(bla))

2020-06-10 14:39:04

Right, but it also gives clear examples of looping through a list directly rather than changing the index to an integer.

2020-06-10 14:44:59

oh? I se,  so if we do
for i in trees:
so, i will be a tree?
if not how we could  treet it like a tree then
i'm sorry but that's new to me, sorry for spamming questions

2020-06-10 14:59:05

That is correct. The only time you really use the integer approach is when working with multiple lists.

2020-06-10 15:06:11

oh, thanks

2020-06-11 04:49:22

Hi. I have some python questions as well, and since this is already a pretty big topic about learning python, figured I'd ask here rather than creating a new one.
I was wondering where I could look to learn more about compiling python projects, and including libraries in projects?
I'm at the point where I can write simple programs in python and run them in the console, but I'm really not sure how to progress from here. I think the most complicated thing I've done is a shitty battleship kinda game, typing in coordinates to shoot and such. I would like to learn more about hooking in keyboard, sound and such if possible though, as well as compilation like I said. Docs seem to be kinda scattered, so mainly just not sure wheer to look.
Thanks in advance for any help! smile

Prier practice and preparation prevents piss poor performance!

2020-06-11 05:38:13

My signature or the guides I wrote in the articles room could be a good place to start if you’re looking to create games.