minor changes

This commit is contained in:
j-weissen 2023-01-20 15:52:47 +01:00
parent c052d08e0e
commit 269faca609
5 changed files with 11 additions and 11 deletions

View file

@ -43,7 +43,7 @@ function preload() {
floorImage = loadImage(FLOOR_IMAGE_PATH); floorImage = loadImage(FLOOR_IMAGE_PATH);
} }
function setup() { function setup() {
createCanvas(2000, 1000); createCanvas(1085, 600);
floorHeight = height / 5; floorHeight = height / 5;
setupObstacleConsts(); setupObstacleConsts();
setupFont(); setupFont();

View file

@ -10,8 +10,8 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<script src="./game.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5@1.5.0/lib/p5.js"></script> <script src="https://cdn.jsdelivr.net/npm/p5@1.5.0/lib/p5.js"></script>
<script src="./game.js"></script>
</head> </head>
<body style="background-color: beige;"> <body style="background-color: beige;">
<noscript> <noscript>

View file

@ -7,10 +7,10 @@
<UserScores :userScores="userScores"></UserScores> <UserScores :userScores="userScores"></UserScores>
</div> </div>
<div class="row"> <div class="row">
<Game v-if="user" v-bind:user-id=this.userId class="col" <Game :class="user ? '' : 'hidden'" v-bind:user-id=this.userId class="col"
@gameFinished="this.updateUserScores()"> @gameFinished="this.updateUserScores()">
</Game> </Game>
<Login v-else @userChange="(event) => {this.user = event; this.userId = this.user.id}"> <Login v-if="!user" @userChange="(event) => {this.user = event; this.userId = this.user.id}">
</Login> </Login>
</div> </div>
<div class="row"> <div class="row">
@ -52,8 +52,6 @@ export default defineComponent({
user: null, user: null,
} }
}, },
methods: { methods: {
async fetchFromApi(path: string, method: "GET" | "POST") { async fetchFromApi(path: string, method: "GET" | "POST") {
let res: Response = await fetch(Rest.URL + path, {method: method,}); let res: Response = await fetch(Rest.URL + path, {method: method,});
@ -86,4 +84,7 @@ export default defineComponent({
.everything { .everything {
margin-bottom: 4em; margin-bottom: 4em;
} }
.hidden {
visibility: hidden;
}
</style> </style>

View file

@ -40,9 +40,6 @@ export default {
created() { created() {
this.updatePage(); this.updatePage();
}, },
updated() {
this.updatePage()
},
methods: { methods: {
async fetchPage() { async fetchPage() {
let res = await fetch(`${Rest.URL}/leaderboard/${this.type}?pagination=true&entriesPerPage=${this.entriesPerPage}&page=${this.pageNumber}`, {method: "GET"}); let res = await fetch(`${Rest.URL}/leaderboard/${this.type}?pagination=true&entriesPerPage=${this.entriesPerPage}&page=${this.pageNumber}`, {method: "GET"});

View file

@ -25,8 +25,10 @@ export default {
emits: ['userChange'], emits: ['userChange'],
methods: { methods: {
async setUser() { async setUser() {
let user = await User.getByName(this.username); let user;
if (user.errors) { try {
user = await User.getByName(this.username);
} catch (e) {
user = await User.create(this.username); user = await User.create(this.username);
} }