forked from MrCrayfish/MrCrayfishDeviceMod
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Jab125/1.18
Create snake game
- Loading branch information
Showing
5 changed files
with
396 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
common/src/main/java/com/ultreon/devices/programs/snake/SnakeApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.ultreon.devices.programs.snake; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.ultreon.devices.api.app.Application; | ||
import com.ultreon.devices.api.app.Component; | ||
import com.ultreon.devices.api.app.Dialog; | ||
import com.ultreon.devices.api.app.Layout; | ||
import com.ultreon.devices.api.app.component.Button; | ||
import com.ultreon.devices.api.app.component.Label; | ||
import com.ultreon.devices.api.app.component.Text; | ||
import com.ultreon.devices.core.Laptop; | ||
import com.ultreon.devices.programs.snake.layout.SnakeLayout; | ||
import com.ultreon.devices.programs.system.AppStore; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.nbt.CompoundTag; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static com.ultreon.devices.api.app.component.Button.getTextWidth; | ||
|
||
public class SnakeApp extends Application { | ||
public Layout titleScreen; | ||
public SnakeLayout gameLayout; | ||
@Override | ||
public void init(@Nullable CompoundTag intent) { | ||
this.titleScreen = new Layout(200, 100); | ||
var startButton = new Button(30, 70, "Start"); | ||
startButton.setClickListener(((mouseX, mouseY, mouseButton) -> { | ||
this.gameLayout = new SnakeLayout(this); | ||
this.setCurrentLayout(this.gameLayout); | ||
})); | ||
var titleText = new Label("Snake", 10, 10); | ||
titleText.setScale(2); | ||
|
||
titleScreen.addComponent(titleText); | ||
titleScreen.addComponent(startButton); | ||
setCurrentLayout(titleScreen); | ||
} | ||
|
||
@Override | ||
public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean active, float partialTicks) { | ||
super.render(pose, laptop, mc, x, y, mouseX, mouseY, active, partialTicks); | ||
// for (Component component : this.titleScreen.components) { | ||
// System.out.println(component + "lt: " + component.left + ", " + component.top); | ||
// } | ||
} | ||
|
||
@Override | ||
public void load(CompoundTag tag) { | ||
|
||
} | ||
|
||
@Override | ||
public void save(CompoundTag tag) { | ||
|
||
} | ||
} |
Oops, something went wrong.