This commit is contained in:
jordan4ibanez 2023-12-14 18:53:05 -05:00
parent 6e790ef7e0
commit f7c6f5cae2
3 changed files with 108 additions and 1 deletions

View File

@ -32,7 +32,7 @@ Join my discord to watch me ramble like a maniac: https://discord.gg/Z2wCscTB4F
Please see the source code for more information. I would start in [programs/program.ts](https://github.com/jordan4ibanez/mineos/blob/main/mods/mineos/programs/programs.ts#L10) to see the underlying framework of a Program.
Yes this does have ``System.out.println("hi")`` I don't recommend you use it. But you can if you want.
Yes this does have ``System.out.println("hi")`` I don't recommend you use it. But you can if you want. This was added as a joke.
## Game controls

View File

@ -65,6 +65,8 @@ do
size
)
self.loaded = false
self.scorePlayer = 0
self.scoreEnemy = 0
self.ball = __TS__New(
mineos.AABB,
create(0, 0),
@ -173,6 +175,53 @@ do
z_index = 2
}
)
self.renderer:addElement(
"separator_" .. tostring(self.instance),
{
name = "gong_ball_" .. tostring(self.instance),
hud_elem_type = HudElementType.image,
position = create(0, 0),
text = ("pixel.png^[colorize:" .. colors.color(100, 100, 100)) .. ":255",
scale = create(PIXEL_SIZE / 2, self.windowSize.y),
alignment = create(1, 1),
offset = create(self.windowPosition.x + self.windowSize.y / 2 - PIXEL_SIZE / 4, self.windowPosition.y),
z_index = 2
}
)
self.renderer:addElement(
"gong_player_score_" .. tostring(self.instance),
{
name = "gong_player_score_" .. tostring(self.instance),
hud_elem_type = HudElementType.text,
scale = create(1, 1),
text = tostring(self.scorePlayer),
number = colors.colorHEX(100, 100, 100),
position = create(0, 0),
alignment = create(0, 1),
offset = create(
self.windowPosition.x + self.windowSize.x / 2 - getPixel(2),
self.windowPosition.y + getPixel(1)
),
z_index = 3
}
)
self.renderer:addElement(
"gong_enemy_score_" .. tostring(self.instance),
{
name = "gong_enemy_score_" .. tostring(self.instance),
hud_elem_type = HudElementType.text,
scale = create(1, 1),
text = tostring(self.scoreEnemy),
number = colors.colorHEX(100, 100, 100),
position = create(0, 0),
alignment = create(0, 1),
offset = create(
self.windowPosition.x + self.windowSize.x / 2 + getPixel(2),
self.windowPosition.y + getPixel(1)
),
z_index = 3
}
)
self:setWindowTitle("Gong")
print("Gong loaded!")
self.loaded = true
@ -193,6 +242,11 @@ do
"offset",
self:getBallPos()
)
self.renderer:setElementComponentValue(
"gong_player_score_" .. tostring(self.instance),
"text",
tostring(self.scorePlayer)
)
end
function Gong.prototype.playerControls(self, delta)
local up = self.system:isKeyDown("up")

View File

@ -29,6 +29,9 @@ namespace mineos {
static currentInstance = 0
scorePlayer = 0
scoreEnemy = 0
ball = new AABB(
create(0,0),
create(getPixel(1),getPixel(1)),
@ -142,6 +145,55 @@ namespace mineos {
z_index: 2
})
this.renderer.addElement("separator_" + this.instance, {
name: "gong_ball_" + this.instance,
hud_elem_type: HudElementType.image,
position: create(0,0),
text: "pixel.png^[colorize:" + colors.color(100,100,100) + ":255",
scale: create(
PIXEL_SIZE / 2,
this.windowSize.y
),
alignment: create(1,1),
offset: create(
this.windowPosition.x + (this.windowSize.y / 2) - (PIXEL_SIZE / 4),
this.windowPosition.y
),
z_index: 2
})
this.renderer.addElement("gong_player_score_" + this.instance, {
name: "gong_player_score_" + this.instance,
hud_elem_type: HudElementType.text,
scale: create(1,1),
text: this.scorePlayer.toString(),
number: colors.colorHEX(100,100,100),
position: create(0,0),
alignment: create(0,1),
offset: create(
this.windowPosition.x + (this.windowSize.x / 2) - getPixel(2),
this.windowPosition.y + getPixel(1)
),
// style: 4,
z_index: 3
})
this.renderer.addElement("gong_enemy_score_" + this.instance, {
name: "gong_enemy_score_" + this.instance,
hud_elem_type: HudElementType.text,
scale: create(1,1),
text: tostring(this.scoreEnemy),
number: colors.colorHEX(100,100,100),
position: create(0,0),
alignment: create(0,1),
offset: create(
this.windowPosition.x + (this.windowSize.x / 2) + getPixel(2),
this.windowPosition.y + getPixel(1)
),
// style: 4,
z_index: 3
})
this.setWindowTitle("Gong")
@ -153,6 +205,7 @@ namespace mineos {
this.renderer.setElementComponentValue("gong_player_paddle_" + this.instance, "offset", this.getPlayerPaddlePos())
this.renderer.setElementComponentValue("gong_enemy_paddle_" + this.instance, "offset", this.getEnemyPaddlePos())
this.renderer.setElementComponentValue("gong_ball_" + this.instance, "offset", this.getBallPos())
this.renderer.setElementComponentValue("gong_player_score_" + this.instance, "text", tostring(this.scorePlayer))
}
playerControls(delta: number): void {