在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:goplus/spx开源软件地址:https://github.com/goplus/spx开源编程语言:Go 98.7%开源软件介绍:spx - A Go+ 2D Game Engine for STEM educationHow to buildHow to run games powered by Go+ spx engine?
Games powered by spxTutorialstutorial/01-WeatherThrough this example you can learn how to listen events and do somethings. Here are some codes in Kai.spx: onStart => {
say "Where do you come from?", 2
broadcast "1"
}
onMsg "2", => {
say "What's the climate like in your country?", 3
broadcast "3"
}
onMsg "4", => {
say "Which seasons do you like best?", 3
broadcast "5"
} We call When the program starts, Kai says onMsg "1", => {
say "I come from England.", 2
broadcast "2"
}
onMsg "3", => {
say "It's mild, but it's not always pleasant.", 4
# ...
broadcast "4"
} Yes, Jaime recieves the message The following procedures are very similar. In this way you can implement dialogues between multiple actors. tutorial/02-DragonThrough this example you can learn how to define variables and show them on the stage. Here are all the codes of Dragon: var (
score int
)
onStart => {
score = 0
for {
turn rand(-30, 30)
step 5
if touching("Shark") {
score++
play chomp, true
step -100
}
}
} We define a variable named How to show the {
"zorder": [
{
"type": "stageMonitor",
"target": "Dragon",
"val": "getVar:score",
"color": 15629590,
"label": "score",
"mode": 1,
"x": 5,
"y": 5,
"visible": true
}
]
} tutorial/03-CloneThrough this example you can learn:
Here are some codes in Calf.spx: var (
id int
)
onClick => {
clone
}
onCloned => {
gid++
...
} When we click the sprite In Here are all the codes of index.gmx: var (
Arrow Arrow
Calf Calf
gid int
)
run "res", {Title: "Clone and Destory (by Go+)"} All these three variables in index.gmx are shared by all sprites. Let's back to Calf.spx to see the full codes of onCloned => {
gid++
id = gid
step 50
say id, 0.5
} It increases Why these Here are all the codes in Arrow.spx: onClick => {
broadcast "undo", true
gid--
} When we click All onMsg "undo", => {
if id == gid {
destroy
}
} tutorial/04-BulletThrough this example you can learn:
It's simple to keep a sprite following mouse position. Here are some related codes in MyAircraft.spx: onStart => {
for {
# ...
setXYpos mouseX, mouseY
}
} Yes, we just need to call But how to fire bullets? Let's see all codes of MyAircraft.spx: onStart => {
for {
wait 0.1
Bullet.clone
setXYpos mouseX, mouseY
}
} In this example, Here are all the codes in Bullet.spx: onCloned => {
setXYpos MyAircraft.xpos, MyAircraft.ypos+5
show
for {
wait 0.04
changeYpos 10
if touching(Edge) {
destroy
}
}
} When a At last, when the These are all things about firing bullets. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论