update V game

This commit is contained in:
Alexander Popov 2024-05-11 21:12:26 +03:00
parent 18710fa443
commit a8e26be242
Signed by: iiiypuk
GPG Key ID: E47FE0AB36CD5ED6
14 changed files with 136 additions and 16 deletions

View File

@ -1,4 +0,0 @@
* draw rect
* draw text
* draw image
* key event

1
projects/V/Game/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
Game

82
projects/V/Game/README.md Normal file
View File

@ -0,0 +1,82 @@
* draw rect
* draw text
* draw image
* key event
## Build
### Linux
`...`
### Android
**Подготовка Android окружения**.
Необходимо выполнить следующие шаги:
1. Установка модуля `vab` для **V**
2. Установка **Android NDK**
3. Установка **android-tools**
4. Получение идентификатора устройства для деплоя
**Установка модуля `vab` для V**
```sh
v install vab
# Installed `vab` in ~/.vmodules/vab .
vab install "platforms;android-33" # Silent output... wait!
```
**Получение идентификатора устройства**
```sh
adb devices -l
```
https://developer.android.com/ndk
https://dl.google.com/android/repository/android-ndk-r26d-linux.zip
https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
Сборка `debug` пакета.
```sh
ANDROID_NDK_ROOT="/home/user/.android/android-ndk-r26d"
VAB_FLAGS="-v 3 --name 'V App' --api 33 --build-tools 29.0.0" ~/.vmodules/vab/vab .
~/.vmodules/vab/vab --device ca4fcde6 run /home/user/Develop/snipplets.dev/projects/V/Game/v_app.apk
```
Сборка `release` пакета:
```sh
# Генерация sign.keystore
keytool -genkey -v -keystore sign.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
```
```sh
KEYSTORE_PASSWORD="Mix9BEAH" \
KEYSTORE_ALIAS_PASSWORD="Mix9BEAH" \
VAB_FLAGS="-v 3 --name 'V App' --api 33 --build-tools 29.0.0" \
~/.vmodules/vab/vab -prod --name "V App" --package-id "me.a2s.example" --icon ./assets/vlang.png --version-code 1 \
--keystore ./sign.keystore --keystore-alias "alias_name" .
```
### HTML (WASM)
Guide: https://github.com/vlang/v/tree/master/examples/2048#compiling-to-wasm
## OTHER
```sh
VCROSS_COMPILER_NAME=/home/user/.android/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-17 /home/user/.local/bin/vlang/v -os android .
VCROSS_COMPILER_NAME=/home/user/.android/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-17 /home/user/.local/bin/vlang/v -os android -nocache -cc clang .
ANDROID_SDK_ROOT="/home/user/.android/sdk/cmdline-tools/33" ANDROID_NDK_ROOT="/home/user/.android/android-ndk-r26d" ANDROID_PACKAGE_NAME="test app" ANDROID_PACKAGE_ID="me.a2s.example" VAB_FLAGS="-v 3 --name $ANDROID_PACKAGE_NAME --package-id $ANDROID_PACKAGE_ID --api 33 --build-tools 26.0.2" /home/user/.vmodules/vab/vab .
VCROSS_COMPILER_NAME=/home/user/.android/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-17 /home/user/.local/bin/vlang/v -os android -nocache -cc clang -DSOKOL_GLES3 -dump-modules "/tmp/vab/v/v.modules" -dump-c-flags "/tmp/vab/v/v.cflags" .
VCROSS_COMPILER_NAME=/home/user/.android/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang /home/user/.local/bin/vlang/v -os android android.v
```

BIN
projects/V/Game/android Executable file

Binary file not shown.

View File

@ -0,0 +1,3 @@
fn main() {
print('Loading... ')
}

View File

@ -0,0 +1 @@
../../../../assets/monogram-extended.ttf

View File

@ -0,0 +1 @@
../../../../assets/tiled_bg.png

View File

@ -0,0 +1 @@
../../../../assets/languages/vlang.png

30
projects/V/Game/build.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# Обновление PATH
PATH="~/.local/bin/vlang:~/.vmodules/vab:$PATH"
# Настройки Android
export ANDROID_SDK_ROOT="/home/user/.android/sdk/cmdline-tools/33"
export ANDROID_NDK_ROOT="/home/user/.android/android-ndk-r26d"
ANDROID_DEVICE_ID="ca4fcde6"
ANDROID_PACKAGE_NAME="test app"
ANDROID_PACKAGE_ID="me.a2s.example"
VAB_FLAGS_DEBUG="-v 3 --name $ANDROID_PACKAGE_NAME --package-id $ANDROID_PACKAGE_ID --api 33 --build-tools 29.0.0"
VAB_FLAGS_RELEASE="-v 3 --name $ANDROID_PACKAGE_NAME --package-id $ANDROID_PACKAGE_ID --api 33 --build-tools 29.0.0 --icon ./assets/vlang.png --version-code 1 --keystore ./sign.keystore --keystore-alias \"alias_name\""
debug() {
VAB_FLAGS=$VAB_FLAGS_DEBUG vab $(pwd)
# vab --device $ANDROID_DEVICE_ID run ./v_app.apk
}
release() {
echo "WIP"
}
test() {
VAB_FLAGS="-v 3 --name $ANDROID_PACKAGE_NAME --package-id $ANDROID_PACKAGE_ID --api 33 --build-tools 26.0.2" vab android.v
}
test

View File

@ -12,7 +12,7 @@ fn (game &Game) draw() {
gx.white, 'right', 'top', true) gx.white, 'right', 'top', true)
// draw image // draw image
game.gg.draw_image(0, game.gg.window_size().height - game.player.image.height, game.player.image.width, game.gg.draw_image(game.player.pos_x, game.player.pos_y, game.player.image.width,
game.player.image.height, game.player.image) game.player.image.height, game.player.image)
game.gg.end() game.gg.end()

View File

@ -3,10 +3,8 @@ import gg
import gx import gx
import sokol.sapp import sokol.sapp
const ( const win_width = 768
win_width = 512 const win_height = 768
win_height = 512
)
struct Game { struct Game {
mut: mut:
@ -39,7 +37,7 @@ fn main() {
print('Loading... ') print('Loading... ')
mut game := &Game{} mut game := &Game{}
mut font_path := os.resource_abs_path(os.join_path('..', '..', '.assets', 'monogram-extended.ttf')) mut font_path := os.resource_abs_path(os.join_path('assets', 'monogram-extended.ttf'))
game.gg = gg.new_context( game.gg = gg.new_context(
bg_color: gx.hex(0x2A2A3AFF) bg_color: gx.hex(0x2A2A3AFF)
@ -55,8 +53,8 @@ fn main() {
) )
game.player = &Player{ game.player = &Player{
pos_x: 10 pos_x: 50
pos_y: 10 pos_y: 50
lives: 3 lives: 3
} }
@ -65,10 +63,10 @@ fn main() {
pos_y: 0 pos_y: 0
} }
game.bg_texture.image = game.gg.create_image(os.resource_abs_path(os.join_path('..', game.bg_texture.image = game.gg.create_image(os.resource_abs_path(os.join_path('assets',
'..', '.assets', 'fondo para itchio.png'))) or { panic(err) } 'tiled_bg.png'))) or { panic(err) }
game.player.image = game.gg.create_image(os.resource_abs_path(os.join_path('..', '..', game.player.image = game.gg.create_image(os.resource_abs_path(os.join_path('assets',
'.assets', 'v-logo.png'))) or { panic(err) } 'vlang.png'))) or { panic(err) }
println('OK!\n') println('OK!\n')
println('High DPI: ${gg.high_dpi()}') println('High DPI: ${gg.high_dpi()}')

7
projects/V/Game/v.mod Normal file
View File

@ -0,0 +1,7 @@
Module {
name: 'game',
description: '...',
version: '0.0.0',
repo_url: '...',
dependencies: []
}