Skip to content

examples: add a small breakout game - #23861

Merged
spytheman merged 2 commits into
vlang:masterfrom
spytheman:examples_add_breakout
Mar 5, 2025
Merged

spytheman merged 2 commits into
vlang:masterfrom
spytheman:examples_add_breakout

Conversation

@spytheman

@spytheman spytheman commented Mar 4, 2025 •

Copy link
Copy Markdown
Contributor

It looks like this:
image

I've tested it with wasm too, compiling with:

./v -prod -os wasm32_emscripten -o examples/breakout/breakout.js examples/breakout/

and then:

emrun examples/breakout/breakout.html

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22265

@larpon

larpon commented Mar 5, 2025 •

Copy link
Copy Markdown
Contributor

There's some Audio API problems on Android it seems:

vab --min-sdk-version 29 --nocache --package-id io.v.examples.breakout --name "V Breakout" ~/Downloads/breakout.v
notice: It looks like your app might have crashed. Dumping crash buffer...
details:
  --------- beginning of crash
  03-05 09:46:14.743 27018 27018 E AndroidRuntime: FATAL EXCEPTION: main
  03-05 09:46:14.743 27018 27018 E AndroidRuntime: Process: io.v.examples.breakout, PID: 27018
  03-05 09:46:14.743 27018 27018 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "AAudio_createStreamBuilder" referenced by "/data/app/~~DHzHdNIIucQoUPUDk4LGOA==/io.v.examples.breakout-9MdtlA0P9YuMxVaYnewbew==/lib/arm64/libv_breakout.so"...
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at java.lang.Runtime.loadLibrary0(Runtime.java:1081)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at java.lang.System.loadLibrary(System.java:1765)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at io.v.examples.breakout.VActivity.<clinit>(VActivity.java:6)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at java.lang.Class.newInstance(Native Method)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.Instrumentation.newActivity(Instrumentation.java:1328)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4038)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4325)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.os.Handler.dispatchMessage(Handler.java:106)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.os.Looper.loopOnce(Looper.java:226)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.os.Looper.loop(Looper.java:313)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at android.app.ActivityThread.main(ActivityThread.java:8757)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at java.lang.reflect.Method.invoke(Native Method)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
  03-05 09:46:14.743 27018 27018 E AndroidRuntime:      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
  03-05 09:46:15.994 27062 27062 E AndroidRuntime: FATAL EXCEPTION: main
  03-05 09:46:15.994 27062 27062 E AndroidRuntime: Process: io.v.examples.breakout, PID: 27062

It may just be my device, I am not sure 🤷‍♂️

@larpon

larpon commented Mar 5, 2025

Copy link
Copy Markdown
Contributor

Fixed in #23869
Screenshot_20250305_102159_V Breakout

@larpon

larpon commented Mar 5, 2025

Copy link
Copy Markdown
Contributor

(The odd screen/canvas size is a sokol_app related thing - if the app is suspended and reopened the size is fixed:
Screenshot_20250305_104135_V Breakout

@larpon

larpon commented Mar 5, 2025 •

Copy link
Copy Markdown
Contributor

If we add mouse/touch paddle movement support the game could be very fit for mobile gaming 🙂

@spytheman

Copy link
Copy Markdown
Contributor Author

We could copy some of the touch handling logic from Tetris/2048.

@spytheman

Copy link
Copy Markdown
Contributor Author

How big is the APK for you?

@larpon

larpon commented Mar 5, 2025 •

Copy link
Copy Markdown
Contributor

How big is the APK for you?

For an APK build with support for all 4 default architectures it's:

ls -al
total 8604
drwxr-xr-x 17 lmp lmp    4096  5 mar 10:56 .
drwxrwxr-x 61 lmp lmp    4096 19 feb 13:38 ..
... (redacted)
-rw-r--r--  1 lmp lmp 2663239  5 mar 10:56 v_test_app.apk

So ~2.5 MiB
image

Mind you the armeabi/armeabi-v7a is for compatibility with old devices. For one arch arm64-v8a it's 528,5 KiB:
image

@spytheman
spytheman force-pushed the examples_add_breakout branch from 88b2ee2 to b3e5bca Compare March 5, 2025 11:09
@spytheman
spytheman merged commit 2dc5f68 into vlang:master Mar 5, 2025
@spytheman
spytheman deleted the examples_add_breakout branch March 5, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants