Skip to content

Commit

Permalink
Merge pull request #265 from /issues/251-sprites-take-2
Browse files Browse the repository at this point in the history
Sprites Take 2
  • Loading branch information
alecpm authored Aug 16, 2023
2 parents f5e511e + b935f25 commit 5b01519
Show file tree
Hide file tree
Showing 15 changed files with 848 additions and 462 deletions.
40 changes: 21 additions & 19 deletions dlgr/griduniverse/game_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ item_defaults:
# of this type.
spawn_rate: 1.0

# Visual representation of this item in the UI.
# This value can be any of:
# - A single hex color value, prefixed with "color:". Example: "color:#8a9b0f"
# - A comma-separated pair of hex colors representing the items immature and mature
# states (rendered color will be along a continuum between these colors based on
# current maturity), also prefixed with "color:" Example: "color:#8a9b0f,#7a6b54"
# Visual representation of this item in the UI. This value can be any of:
# - A single hex color value, prefixed with "color:". Example:
# "color:#8a9b0f"
# - A comma-separated pair of hex colors representing the items immature
# and mature states (rendered color will be along a continuum between
# these colors based on current maturity), also prefixed with "color:"
# Example: "color:#8a9b0f,#7a6b54"
# - A unicode emoji, prefixed with "emoji:". Example: "emoji:🍓"
# - The path of an image in within the images/ folder, prefixed with "image:".
# Example ("image:sprites/strawberry.png")
# - A url for an image or a path to an image in within the static/images/
# folder, prefixed with "image:". Example
# ("image:sprites/strawberry.png")
sprite: "color:#8a9b0f,#7a6b54"

transition_defaults:
Expand Down Expand Up @@ -189,13 +191,13 @@ items:
respawn: true
item_count: 8
limit_quantity: true
sprite: "#8a9b0f,#7a6b54"
sprite: "color:#8a9b0f,#7a6b54"

- item_id: food2
calories: 3
crossable: true
interactive: false
item_count: 4
item_count: 50
maturation_speed: 0.2
maturation_threshold: 0.5
n_uses: 1
Expand All @@ -205,7 +207,7 @@ items:
portable: true
respawn: true
limit_quantity: true
sprite: "#2a9b0f,#1a6b54"
sprite: "image:sprites/food.png"

# One Hour, One Life items
- crossable: true
Expand All @@ -215,7 +217,7 @@ items:
portable: true
spawn_rate: 0.15
item_count: 100
sprite: "#E67E22"
sprite: "emoji:🥕"

- crossable: true
interactive: true
Expand All @@ -224,7 +226,7 @@ items:
portable: true
spawn_rate: 0.05
item_count: 50
sprite: "#95A5A6"
sprite: "image:https://github.githubassets.com/images/icons/emoji/unicode/1faa8.png?v8"

- crossable: true
interactive: true
Expand All @@ -233,7 +235,7 @@ items:
portable: false
spawn_rate: 0
item_count: 20
sprite: "#7F8C8D"
sprite: "emoji:🗿"

- crossable: true
interactive: true
Expand All @@ -243,7 +245,7 @@ items:
portable: false
spawn_rate: 0.1
item_count: 50
sprite: "#8E44AD"
sprite: "emoji:🌳"

- crossable: true
interactive: true
Expand All @@ -252,7 +254,7 @@ items:
portable: true
spawn_rate: 0.05
item_count: 20
sprite: "#BDC3C7"
sprite: "emoji:💎"

- calories: 5
crossable: true
Expand All @@ -263,7 +265,7 @@ items:
portable: true
spawn_rate: 0
item_count: 0
sprite: "#E67E22"
sprite: "emoji:🥕"

- calories: 3
crossable: true
Expand All @@ -274,7 +276,7 @@ items:
portable: true
spawn_rate: 0
item_count: 0
sprite: "#8E44AD"
sprite: "emoji:🫐"

- crossable: false
interactive: true
Expand All @@ -284,7 +286,7 @@ items:
portable: false
spawn_rate: 0
item_count: 0
sprite: "#9B59B6"
sprite: "emoji:🌴"

transitions:
- actor_start: stone
Expand Down
Binary file added dlgr/griduniverse/static/images/sprites/food.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions dlgr/griduniverse/static/scripts/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Section {
if (x >= this.left && x < this.left + this.columns) {
if (y >= this.top && y < this.top + this.rows) {
this.data[this.gridCoordsToSectionIdx(x, y)] = color;
if (! _.isUndefined(texture)){
if (! _.isNil(texture)) {
this.textures[this.gridCoordsToSectionIdx(x, y)] = texture;
}
background[coordsToIdx(x, y, settings.columns)] = color;
Expand Down Expand Up @@ -117,6 +117,8 @@ var pixels = grid(initialSection.data, initialSection.textures, {
size: settings.block_size,
padding: settings.padding,
background: [0.1, 0.1, 0.1],
item_config: settings.item_config,
sprites_url: settings.sprites_url,
formatted: true
});

Expand Down Expand Up @@ -609,7 +611,11 @@ pixels.frame(function() {
gridItems.remove(position);
}
} else {
section.plot(position[1], position[0], item.color);
var texture = undefined;
if (item.item_id in pixels.itemTextures) {
texture = item.item_id;
}
section.plot(position[1], position[0], item.color, texture);
}
}

Expand Down
4 changes: 2 additions & 2 deletions dlgr/griduniverse/static/scripts/dist/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.js -diff -merge
*.js -diff merge=ours
*.js linguist-generated=true
*.map -diff -merge
*.map -diff merge=ours
*.map linguist-generated=true
Loading

0 comments on commit 5b01519

Please sign in to comment.