- Edited
Hello. I have experience in pygame and decided transport projects from python to godot. Almost immediately in view of the absence of good gdscript docs I got a problem with classes. For example, I have the same class in python
def some():
pass
class PriorityStack:
def __init__(self):
self.elements = []
def put(self, item, priority):
if self.empty():
self.elements.append((item, priority))
else:
for el in self.elements:
if priority <= el[1]:
self.elements.insert(self.elements.index(el), (item, priority))
break
else:
self.elements.append((item, priority))
def get(self):
return self.elements.pop(0)[0]
def empty(self):
return len(self.elements) == 0
def __len__(self):
return len(self.elements)
And is it posiible to rewrite this class in gdscript without creating new scene? I've read that godot's script is already classes, but how can I use them? Thanks that you read this. P.S First function for coverage whole code, because this redactor wouldn't accept class header and init function