Skip to content

Commit

Permalink
所持品検査
Browse files Browse the repository at this point in the history
  • Loading branch information
jnc-explosion committed Jan 29, 2024
1 parent a34559e commit da8b1b2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/engine/components/Text.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Text: Component {
private string _text;
SDL_Color c;

bool enable = true;

this(TextAsset asset) {
_font = asset;
c.a = 255;
Expand Down Expand Up @@ -60,6 +62,7 @@ class Text: Component {
}

override void loop() {
if(!enable) return;
int voffset = 0;
foreach(texture; textures) {
if(texture is null) {
Expand Down
29 changes: 29 additions & 0 deletions src/game/entities/BombMeter.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module game.entities.BombMeter;

import engine;
import game;

class BombMeter : GameObject {
Transform tf;
ImageBox[] ib;
TextBox tb;

this(){
tf = register(new Transform(tf.Org.Local));
tf.pos = Vec2(700, 0);
foreach(i; 0..3) ib ~= register(new ImageBox("bomb.png"));
foreach(i, ref imbx; ib) {
imbx.component!Transform.pos = Vec2(i*100, 0);
imbx.component!Transform.scale = Vec2(0.2, 0.2);
}
tb = register(new TextBox("+いっぱい", Vec2(300, 0)));
}

override void loop() {
foreach(i, ref imbx; ib){
if(i < gm.heroStatus.haveObj.length) imbx.component!SpriteRenderer.enable = true;
else imbx.component!SpriteRenderer.enable = false;
}
tb.component!Text.enable = (gm.heroStatus.haveObj.length > 3);
}
}
3 changes: 3 additions & 0 deletions src/game/entities/UI.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class UI: GameObject {
// points
register(new Point);

// bombs
register(new BombMeter);

// and more...
}

Expand Down
1 change: 1 addition & 0 deletions src/game/entities/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public import game.entities.Enemy4;
public import game.entities.Enemy5;
public import game.entities.Boss;
public import game.entities.Bomb;
public import game.entities.BombMeter;
public import game.entities.Hero;
public import game.entities.Kalashnikov;
public import game.entities.LifeIndicator;
Expand Down

0 comments on commit da8b1b2

Please sign in to comment.