zoukankan      html  css  js  c++  java
  • MaxScript键盘控制盒子的移动

    悲剧的是,只能在32位版本下使用,需要Max2008或更高版本,如果需要在其他版本下,其实也并非不可,只是会比较麻烦,此外,这种东西找个引擎来做更简单一些

    View Code
    DotNet.loadAssembly "Microsoft.VisualBasic.dll"
    DotNet.loadAssembly
    "Microsoft.DirectX.DirectInput.dll"
    Global KeyboardDevice

    SystemGuid
    = DotNetClass "Microsoft.DirectX.DirectInput.SystemGuid"
    KeyboardDevice
    = DotNetObject "Microsoft.DirectX.DirectInput.Device" SystemGuid.Keyboard
    CooperativeLevelFlags
    = DotNetClass "Microsoft.DirectX.DirectInput.CooperativeLevelFlags"
    theCooperativeLevelFlags
    = DotNet.CompareEnums CooperativeLevelFlags.Background CooperativeLevelFlags.NonExclusive 2
    MaxHWND
    = DotNetObject "System.IntPtr" (Windows.getMAXHWND() as integer)
    KeyboardDevice.SetCooperativeLevel MaxHWND theCooperativeLevelFlags
    KeyboardDevice.Acquire()


    Fn TimerUpDate theSender TheEvent
    =
    (
    Global Boxer,KeyboardDevice
    if not IsValidNode Boxer do Boxer = Box()
    moveStep
    = 1
    DxKey
    = DotNetClass "Microsoft.DirectX.DirectInput.Key"
    KeyboardState
    = KeyboardDevice.GetCurrentKeyboardState()

    if (KeyboardState.item DXKey.D) == true do Boxer.Pos.X += moveStep
    if (KeyboardState.item DXKey.A) == true do Boxer.Pos.X -= moveStep
    if (KeyboardState.item DXKey.W) == true do Boxer.Pos.Y += moveStep
    if (KeyboardState.item DXKey.S) == true do Boxer.Pos.Y -= moveStep

    )
    DotNetTimer
    = DotNetObject"System.Timers.Timer" 30
    DotNet.AddEventHandler DotNetTimer
    "Elapsed" TimerUpDate
    DotNetTimer.Start()
  • 相关阅读:
    Windows安装使用wget
    Ubuntu16.04 安装和卸载MySQL数据库
    申请百度翻译API
    Linux配置JDK
    vmware的三种网络连接模式
    3、linux-目录管理:mkdir、rmdir、mv
    2、linux-添加组groupadd、修改组groupmod、删除组groupdel
    1、linux-用户管理useradd,usermod,userdel
    在Linux操作系统里有Ext2、Ext3、Linux swap和VFAT四种格式
    第四次作业 简易计算器
  • 原文地址:https://www.cnblogs.com/sitt/p/2100510.html
Copyright © 2011-2022 走看看