ad208三国

 找回密码
 加入
搜索
热搜: 活动 交友 discuz
查看: 484|回复: 0

Rust+WebAssembly开发的一个小游戏SpaceOut

[复制链接]
发表于 2023-7-8 20:23:52 | 显示全部楼层 |阅读模式

pc2g,电脑好游戏
  基于 nphysics2d, direct2d 和 stdweb

游戏源码参考《游戏编程入门》:

Rust WebAssembly 入门参考这里:https://www.hellorust.com/setup/wasm-target/

代码结构:

html部分
html 游戏资源文件和HTML文件

游戏引擎部分
src/engine.rs 游戏引擎
src/sprite.rs 精灵
src/timer.rs 计时器

SpaceOut游戏
src/game.rs 游戏主代码
src/alien_sprite.rs 外星人
src/backgkround.rs 星星闪烁的背景

编译
cargo  +nightly build --target wasm32-unknown-unknown --release
copy target\wasm32-unknown-unknown\release\spaceout.wasm html\spaceout.wasm
然后浏览器打开html/index.html就可以运行了。

游戏可以在github空间玩:http://planet0104.github.io/spaceout
在线试玩:https://planet0104.github.io/spaceout/deploy/index.html
作为对比,这是javascript版本:http://planet0104.github.io/spaceout_js/

Archiver|手机版|小黑屋|ad208三国

GMT+8, 2024-4-29 07:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表