add tower builing game

This commit is contained in:
hamid zarghami
2025-12-09 10:48:48 +03:30
parent 8119203506
commit 53b9139506
79 changed files with 15363 additions and 3 deletions
+35
View File
@@ -0,0 +1,35 @@
import { getHookStatus } from './utils'
import * as constant from './constant'
export const tutorialAction = (instance, engine, time) => {
const { width, height } = engine
const { name } = instance
if (!instance.ready) {
instance.ready = true
const tutorialWidth = width * 0.2
instance.updateWidth(tutorialWidth)
instance.height = tutorialWidth * 0.46
instance.x = engine.calWidth - instance.calWidth
instance.y = height * 0.45
if (name !== 'tutorial') {
instance.y += instance.height * 1.2
}
}
if (name !== 'tutorial') {
instance.y += Math.cos(time / 200) * instance.height * 0.01
}
}
export const tutorialPainter = (instance, engine) => {
if (engine.checkTimeMovement(constant.tutorialMovement)) {
return
}
if (getHookStatus(engine) !== constant.hookNormal) {
return
}
const { ctx } = engine
const { name } = instance
const t = engine.getImg(name)
ctx.drawImage(t, instance.x, instance.y, instance.width, instance.height)
}