-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGameUtils.py
81 lines (67 loc) · 1.56 KB
/
GameUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /usr/bin/python3
import sys
import getopt
def use():
print('GameUtils.py --element=system|script --name=scriptName --author=Simon AMBROISE')
def main(argv):
element = ''
name = ''
author = ''
try:
opts, args = getopt.getopt(argv, "h", ["element=", "name=", "author="])
except getopt.GetoptError:
use()
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
use()
sys.exit()
elif opt in "--element":
element = arg
elif opt in "--name":
name = arg
if name == '':
use()
sys.exit(2)
if author == '':
author = 'Simon AMBROISE'
if element == 'system':
print('system')
elif element == 'script':
with open('./Game/src/Game/Scripts/'+name+'.cpp', 'w+') as srcFile:
srcFile.write("""/*
** @Author : %s
*/
#include <Engine/Components.hh>
#include <Game/Scripts/%s.hpp>
void %s::start()
{
}
void %s::update(float dt)
{
}
""" % (author, name, name, name))
srcFile.close()
with open('./Game/include/Game/Scripts/'+name+'.hpp', 'w+') as includeFile:
includeFile.write("""/*
** @Author : %s
*/
#pragma once
#include <Engine/Core/ScriptFactory.hpp>
class %s : public BaseScript
{
public:
%s() {};
~%s() {};
public:
virtual void start();
virtual void update(float dt);
};
REGISTER_SCRIPT(%s);
""" % (author, name, name, name,name))
includeFile.close()
else:
use()
sys.exit(2)
if __name__ == "__main__":
main(sys.argv[1:])