Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game-stydy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
谌继荃
game-stydy
Commits
872e687d
Commit
872e687d
authored
Nov 20, 2021
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
8598e278
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
EnemyFactory.ts
src/planewar/EnemyFactory.ts
+14
-3
addGame.ts
src/planewar/addGame.ts
+2
-3
No files found.
src/planewar/EnemyFactory.ts
View file @
872e687d
import
MovableManager
from
"../lib/MovableManager"
;
import
Vector2
from
"../lib/Vector2"
;
import
Enemy
from
"./Enemy"
;
export
default
class
EnemyFactory
{
export
default
class
EnemyFactory
{
private
_timer
;
private
_timer
;
constructor
()
{
private
_stage
:
FYGE
.
Stage
;
this
.
_timer
=
setInterval
(
this
.
onTimer
,
10
*
1000
)
movableManager
:
MovableManager
constructor
(
stage
:
FYGE
.
Stage
,
movableManager
:
MovableManager
)
{
this
.
movableManager
=
movableManager
;
this
.
_stage
=
stage
;
this
.
_timer
=
setInterval
(
this
.
onTimer
,
1000
)
}
}
onTimer
=
()
=>
{
onTimer
=
()
=>
{
const
enemy
=
this
.
_stage
.
addChild
(
new
Enemy
(
this
.
movableManager
));
enemy
.
position
.
set
(
Math
.
random
()
*
300
+
200
,
0
);
enemy
.
velocity
=
new
Vector2
((
Math
.
random
()
-
0.5
)
*
2
,
Math
.
random
()
*
5
+
2
);;
}
}
destroy
()
{
destroy
()
{
...
...
src/planewar/addGame.ts
View file @
872e687d
...
@@ -3,6 +3,7 @@ import DragDropManager from "../dragdrop/DragDropManager";
...
@@ -3,6 +3,7 @@ import DragDropManager from "../dragdrop/DragDropManager";
import
MovableManager
from
"../lib/MovableManager"
;
import
MovableManager
from
"../lib/MovableManager"
;
import
Vector2
from
"../lib/Vector2"
;
import
Vector2
from
"../lib/Vector2"
;
import
Enemy
from
"./Enemy"
;
import
Enemy
from
"./Enemy"
;
import
EnemyFactory
from
"./EnemyFactory"
;
import
Hero
from
"./Hero"
;
import
Hero
from
"./Hero"
;
...
@@ -13,9 +14,7 @@ export function addGame(stage: FYGE.Stage) {
...
@@ -13,9 +14,7 @@ export function addGame(stage: FYGE.Stage) {
const
hero
=
stage
.
addChild
(
new
Hero
(
movableManager
))
as
DragDropable
;
const
hero
=
stage
.
addChild
(
new
Hero
(
movableManager
))
as
DragDropable
;
hero
.
position
.
set
(
300
,
1000
);
hero
.
position
.
set
(
300
,
1000
);
const
enemy
=
stage
.
addChild
(
new
Enemy
(
movableManager
));
const
enemyFactory
=
new
EnemyFactory
(
stage
,
movableManager
);
enemy
.
position
.
set
(
0
,
0
);
enemy
.
velocity
=
new
Vector2
(
4
,
1
);
dragDropManager
.
add
(
hero
);
dragDropManager
.
add
(
hero
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment