Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet INF443 Maé
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Noé ARTRU
Projet INF443 Maé
Commits
fa7b5bab
Commit
fa7b5bab
authored
1 year ago
by
Noé
Browse files
Options
Downloads
Patches
Plain Diff
Files for new projectile structure
parent
2e123f19
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projet-code/scenes_inf443/base/src/projectile.cpp
+67
-0
67 additions, 0 deletions
projet-code/scenes_inf443/base/src/projectile.cpp
projet-code/scenes_inf443/base/src/projectile.hpp
+26
-0
26 additions, 0 deletions
projet-code/scenes_inf443/base/src/projectile.hpp
with
93 additions
and
0 deletions
projet-code/scenes_inf443/base/src/projectile.cpp
0 → 100644
+
67
−
0
View file @
fa7b5bab
#include
"projectile.hpp"
#include
"terrain.hpp"
void
projectile
::
initialize
()
{
N
=
0
;
pos
.
resize
(
N
);
v
.
resize
(
N
);
color
.
resize
(
N
);
elemental_types
.
resize
(
N
);
mesh
.
initialize_data_on_gpu
(
mesh_primitive_sphere
(
0.1
f
));
}
void
projectile
::
reset
()
{
N
=
0
;
pos
.
resize
(
N
);
v
.
resize
(
N
);
color
.
resize
(
N
);
}
void
projectile
::
add_ball
(
vec3
new_pos
,
vec3
new_dir
)
{
N
++
;
pos
.
resize
(
N
);
v
.
resize
(
N
);
color
.
resize
(
N
);
elemental_types
.
resize
(
N
);
pos
[
N
-
1
]
=
new_pos
;
v
[
N
-
1
]
=
new_dir
;
elemental_types
[
N
-
1
]
=
types
[
N
%
5
];
if
(
elemental_types
[
N
-
1
]
==
projectile_type
::
fire
)
{
color
[
N
-
1
]
=
{
0.886
,
0.345
,
0.133
};
}
else
if
(
elemental_types
[
N
-
1
]
==
projectile_type
::
ice
)
{
color
[
N
-
1
]
=
{
1
,
1
,
1
};
}
else
if
(
elemental_types
[
N
-
1
]
==
projectile_type
::
rock
)
{
color
[
N
-
1
]
=
{
0.3
,
0.22
,
0.2
};
}
else
if
(
elemental_types
[
N
-
1
]
==
projectile_type
::
electric
)
{
color
[
N
-
1
]
=
{
1
,
1
,
0.2
};
}
else
if
(
elemental_types
[
N
-
1
]
==
projectile_type
::
water
)
{
color
[
N
-
1
]
=
{
0
,
0
,
1
};
}
}
void
projectile
::
simulate
(
float
dt
,
float
terrain_length
)
{
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
if
(
pos
[
i
][
2
]
<
-
1
||
cgp
::
abs
(
pos
[
i
][
0
])
>
terrain_length
/
2
||
cgp
::
abs
(
pos
[
i
][
1
])
>
terrain_length
/
2
)
{
pos
[
i
]
=
{
0
,
0
,
evaluate_terrain_height
(
0
,
0
,
terrain_length
)
};
v
[
i
]
=
{
3
*
rand_interval
(),
3
*
rand_interval
(),
4
+
i
};
}
else
{
pos
[
i
]
+=
v
[
i
]
*
dt
;
v
[
i
][
2
]
-=
10
*
dt
;
}
if
(
pos
[
i
][
2
]
<
evaluate_terrain_height
(
pos
[
i
][
0
],
pos
[
i
][
1
],
terrain_length
))
{
pos
[
i
]
=
{
0
,
0
,
-
1
};
v
[
i
]
=
{
0
,
0
,
0
};
}
}
}
This diff is collapsed.
Click to expand it.
projet-code/scenes_inf443/base/src/projectile.hpp
0 → 100644
+
26
−
0
View file @
fa7b5bab
#pragma once
#include
"cgp/cgp.hpp"
using
namespace
cgp
;
struct
projectile
{
int
N
;
std
::
vector
<
vec3
>
v
;
std
::
vector
<
vec3
>
pos
;
std
::
vector
<
vec3
>
color
;
mesh_drawable
mesh
;
enum
class
projectile_type
{
fire
,
ice
,
electric
,
rock
,
water
};
std
::
vector
<
projectile_type
>
elemental_types
;
std
::
vector
<
projectile_type
>
types
=
{
projectile_type
::
fire
,
projectile_type
::
ice
,
projectile_type
::
rock
,
projectile_type
::
electric
,
projectile_type
::
water
};
void
initialize
();
void
simulate
(
float
dt
,
float
terrain_length
);
void
add_ball
(
vec3
new_pos
,
vec3
new_dir
);
void
reset
();
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment