【无标题】神器代码岛,枪战代码

一个神器代码岛的枪战代码

console.clear()

console.clear()

// ------------配置------------

const DEFAULT_WEAPON = '步枪'; // 初始武器

// 队伍配置

const TEAM_CONFIG = {

    '蓝队': {

        spawnPoint: '蓝队出生点', // 出生点实体名称

        color: new GameRGBColor(1, 0, 0), // 颜色

    },

    '黄队': {

        spawnPoint: '黄队出生点',

        color: new GameRGBColor(1, 1, 0),

    },

};

// 武器配置

const WEAPON = {

    '散弹枪': {

        damage: 30, // 伤害

        distance: 10, // 射程距离

        interval: 30, // 发射间隔(数值越大, 射速越慢)

        sound: `audio/霰弹枪.mp3`,

    },

    '步枪': {

        damage: 10,

        distance: 30,

        interval: 5,

        sound: `audio/步枪.mp3`,

    },

    '狙击枪': {

        damage: 25,

        distance: 50,

        interval: 40,

        sound: `audio/狙击枪.mp3`,

    },

};

// 头部穿戴配置

const HEAD_WEARABLE_CONFIG = {

    bodyPart: GameBodyPart.HEAD,

    orientation: new GameQuaternion(0, 0, 0, 1), // 调整方向

    scale: new GameVector3(0.7, 0.7, 0.7), // 调整大小

    offset: new GameVector3(0, 0.2, 0), //调整位置

};

// 武器穿戴配置

const WEAPON_WEARABLE_CONFIG = {

    bodyPart: GameBodyPart.TORSO,

    orientation: new GameQuaternion(0, 0, 0, 1), // 装备方向

    scale: new GameVector3(0.9, 0.9, 0.9), // 调整大小

    offset: new GameVector3(0, 0.1, 0.9), //调整位置

};

// 枪口火焰配置

const MUZZLE_FLASH_CONFIG = {

    bodyPart: GameBodyPart.TORSO,

    orientation: new GameQuaternion(0, 0, 0, 1), // 装备方向

    scale: new GameVector3(0.9, 0.9, 0.9), // 调整大小

    offset: new GameVector3(-0.2, 0.3, 2.1), //调整位置

    mesh: `mesh/火花效果.vb`

};

const Quat = new GameQuaternion(0,0,0,1);

const GAME_END_TIME = 60; // 游戏结束时间, 单位秒

const GAME_END_SCORE = 10; // 游戏结束分数

const MIN_GAME_PLAYER_NUM = 2; // 最小游戏人数

const GAME_HALFTIME = 5; // 两局游戏间隔时间, 单位秒

// ----------------------------

const spawnPoint = objectMap(TEAM_CONFIG, ({spawnPoint}, team) => {

    const e = world.querySelector('#' + spawnPoint);

    return e.position.clone(); // 返回出生点位置

});

const defaultWeaponMesh = world.querySelector('#' + DEFAULT_WEAPON).mesh;

let playerState = {}; // 玩家状态

let teamScore = {}; // 队伍分数

let teamNum = {}; // 队伍人数

let gameEndResolve; // 用于结束游戏的函数

// 主函数

(async function main() {

    // 打印开始时间的日志

    console.log(`-------[${new Date().toISOString()}]--------`)

    setup(); // 初始化

    // 主循环, 不断检测并开始新的游戏

    for(;;await sleep(GAME_HALFTIME * 1000)) {

        // 检测人数

        if (world.querySelectorAll('player').length &

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
用vb做一个简单的射击游戏 Option Explicit Dim RandX As Single Dim RandY As Single Dim Score As Single Dim Thisscore As Single Dim Average As Single Dim Shot As Integer Dim Appear As Boolean Dim Distance As Single Private Sub Command1_Click() Timer1.Enabled = True Command3.Enabled = True If Command1.Enabled = True Then Command3.Caption = "暂停" End If Command4.Enabled = True End Sub Private Sub Command2_Click() If Command4.Enabled = True Then MsgBox "请先结束游戏", 48, "警告" Else End End If End Sub Private Sub Command3_Click() Command1.Enabled = False Command3.Caption = "继续" Timer1.Enabled = Not Timer1.Enabled If Timer1.Enabled = True Then Command3.Caption = "暂停" End If End Sub Private Sub Command4_Click() Timer1.Enabled = False Command3.Enabled = False Command1.Enabled = True Picture1.Cls Label1.Caption = "射击:" Label2.Caption = "平均得分:" Label3.Caption = "环数:" Label4.Caption = "总分:" Command4.Enabled = False Command3.Caption = "暂停" End Sub Private Sub Form_Load() Appear = False Timer1.Enabled = False Thisscore = 0 Score = 0 Shot = 0 End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Beep Shot = Shot + 1 Picture1.DrawWidth = 4 Picture1.PSet (X, Y), RGB(255, 0, 0) Distance = Sqr((X - RandX) * (X - RandX) + (Y - RandY) * (Y - RandY)) If Appear And Timer1.Enabled Then Thisscore = 5 - Int(Distance / 10) If Thisscore <= 0 Then Thisscore = 0 End If Score = Score + Thisscore Average = Int((Score / Shot) * 100) / 100 Label1.Caption = "射击:" + Str(Shot) + "发" Label2.Caption = "平均得分:" & Format(Average, "0.00") & "环" Label3.Caption = "环数:" + Str(Thisscore) + "环" Label4.Caption = "总分:" + Str(Score) + "环" End If End Sub Private Sub Timer1_Timer() Dim i As Integer Appear = Appear Xor True RandX = 500 * Rnd() RandY = 370 * Rnd() If Appear Then Form1.Picture1.AutoRedraw = True Picture1.DrawWidth = 1 Picture1.DrawStyle = 0 For i = 10 To 50 Step 10 Picture1.Circle (RandX, RandY), i, RGB(0, 0, 255) Next i Picture1.Line (RandX - 60, RandY)-(RandX + 60, RandY) Picture1.Line (RandX, RandY - 60)-(RandX, RandY + 60) Else Picture1.Cls End If End Sub

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值