FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
daScript/examples/tutorial/tutorial04.das at master · ilyabelow/daScript · GitHub
ilyabelow
/
daScript
Public
forked from
GaijinEntertainment/daScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
daScript
/
examples
/
tutorial
/
tutorial04.das
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (38 loc) · 1.33 KB
Breadcrumbs
daScript
/
examples
/
tutorial
/
tutorial04.das
Copy path
File metadata and controls
43 lines (38 loc) · 1.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
require
tutorial_04
// uncomment the section to generate C++ bindings for the TutorialBaseClass
// this code will generate tutorial04_gen.inc which contains C++ bindings
/*
require fio
require ast
require daslib/cpp_bind
[init]
def generate_cpp_bindings
let root = get_das_root() + "/examples/tutorial/"
fopen(root + "tutorial04_gen.inc","wb") <| $ ( cpp_file )
log_cpp_class_adapter(cpp_file, "TutorialBaseClass", typeinfo(ast_typedecl type<TutorialBaseClass>))
*/
require
rtti
class
ExampleObject
:
TutorialBaseClass
position : float3
velocity : float3
gravity : float = 9.8f
name : string
def
override
update
(
dt
:
float
) :
void
print("update {
name
} for {
dt
}\n")
position += velocity * dt
velocity.y -= gravity * dt
def
override
get_position
:
float3
print("get position for {
name
} => {
position
}\n")
return position
def
add_new_object
(
classPtr
)
add_object(classPtr, class_info(*classPtr))
[
export
]
def
test
print("this tutorial shows possible implementation for deriving from C++ base class\n")
print("tick = {
tick
(
0.0
)}\n")
add_new_object ( new [[ExampleObject() name="A"]] )
for t in range(5)
print("tick = {
tick
(
0.2
)}\n")
add_new_object ( new [[ExampleObject() name="B"]] )
for t in range(5)
print("tick = {
tick
(
0.2
)}\n")
Back
|
FazBrowse Home
|
New Git URL