Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rustproject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
safarik
rustproject
Commits
8554f5f4
Commit
8554f5f4
authored
3 years ago
by
pumapaul
Browse files
Options
Downloads
Patches
Plain Diff
Add new assets in code
parent
b45e23e2
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
src/game_state.rs
+17
-2
17 additions, 2 deletions
src/game_state.rs
src/game_state/textures.rs
+3
-1
3 additions, 1 deletion
src/game_state/textures.rs
with
20 additions
and
3 deletions
src/game_state.rs
+
17
−
2
View file @
8554f5f4
...
...
@@ -392,19 +392,34 @@ impl GameState {
Tile
::
Wall
=>
GameState
::
draw_wall
(
self
,
draw_x
,
draw_y
,
ctx
),
Tile
::
Player
=>
GameState
::
draw_player
(
self
,
draw_x
,
draw_y
,
ctx
),
Tile
::
Enemy
(
_
)
=>
GameState
::
draw_enemy
(
self
,
draw_x
,
draw_y
,
ctx
),
Tile
::
Exit
=>
GameState
::
draw_
tile
(
self
,
Color
::
RED
,
draw_x
,
draw_y
,
ctx
),
Tile
::
Exit
=>
GameState
::
draw_
exit
(
self
,
draw_x
,
draw_y
,
ctx
),
Tile
::
Treasure
(
_
,
_
)
=>
GameState
::
draw_treasure
(
self
,
draw_x
,
draw_y
,
ctx
),
}
}
}
}
fn
draw_exit
(
&
mut
self
,
x
:
usize
,
y
:
usize
,
ctx
:
&
mut
Context
)
{
GameState
::
draw_tile
(
self
,
Color
::
WHITE
,
x
,
y
,
ctx
);
self
.textures.exit
.draw
(
ctx
,
DrawParams
{
position
:
Vec2
::
new
(
x
as
f32
*
33.0
,
y
as
f32
*
33.0
),
scale
:
Vec2
::
new
(
1.0
,
1.0
),
origin
:
Vec2
::
new
(
0.0
,
0.0
),
rotation
:
0.0
,
color
:
Color
::
WHITE
,
})
}
fn
draw_treasure
(
&
mut
self
,
x
:
usize
,
y
:
usize
,
ctx
:
&
mut
Context
)
{
GameState
::
draw_tile
(
self
,
Color
::
WHITE
,
x
,
y
,
ctx
);
self
.textures.treasure
.draw
(
ctx
,
DrawParams
{
position
:
Vec2
::
new
(
x
as
f32
*
33.0
,
y
as
f32
*
33.0
),
scale
:
Vec2
::
new
(
1.0
,
1.0
),
origin
:
Vec2
::
new
(
0.0
,
0.0
),
rotation
:
0.0
,
color
:
Color
::
GREEN
,
color
:
Color
::
WHITE
,
})
}
...
...
This diff is collapsed.
Click to expand it.
src/game_state/textures.rs
+
3
−
1
View file @
8554f5f4
...
...
@@ -9,6 +9,7 @@ pub struct Textures {
pub
player
:
Texture
,
pub
enemy
:
Texture
,
pub
treasure
:
Texture
,
pub
exit
:
Texture
,
}
impl
Textures
{
...
...
@@ -20,7 +21,8 @@ impl Textures {
cross
:
Texture
::
new
(
ctx
,
"./resources/cross.png"
)
?
,
player
:
Texture
::
new
(
ctx
,
"./resources/player_new.png"
)
?
,
enemy
:
Texture
::
new
(
ctx
,
"./resources/foe.png"
)
?
,
treasure
:
Texture
::
new
(
ctx
,
"./resources/tile.png"
)
?
,
treasure
:
Texture
::
new
(
ctx
,
"./resources/chest.png"
)
?
,
exit
:
Texture
::
new
(
ctx
,
"./resources/stairs.png"
)
?
,
})
}
}
\ No newline at end of file
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