⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lua_time.c

📁 lua脚本语言调用allegro游戏程序库的接口-跨平台
💻 C
字号:
/****************************************************************************
**                                                                         **
**                  LuAllegro library - Lua port of Allegro                **
**                       Copyright (C) 2005 Peter Jamroz                   **
**                 e-mail: peterjam at poczta dot onet dot pl              **
**                                                                         **
**        Permission to use, copy, modify, publish this software           **
**    is hereby granted to any person obtaining a copy of this software,   **
**                              FREE OF CHARGE,                            **
**                     under the following conditions:                     **
**                                                                         **
** 1:  The above copyright notice and this permission notice shall be      **
**     included in all copies or substantial portions of the Software.     **
**                                                                         **
** 2:  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,     **
**   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    **
**   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.**
**   IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE LIABLE FOR ANY    **
**   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  **
**   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     **
**   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                **
**                                                                         **
****************************************************************************/
#include <allegro.h>

#include "lua_aleg.h"
#include "lua_time.h"


//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
//---- Chapter: Timer routines -------------------------------------------------------------
//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------
//void rest(unsigned int msec);
static int l_rest(lua_State* L)
{
   rest( (int) lua_tonumber(L,1));
   return 0; 
}

//------------------------------------------------------------------------------------------
//void rest_callback(long time, void (*callback)())
//I am not sure whether above function should be implemented at all

//------------------------------------------------------------------------------------------
static int l_retrace_count(lua_State* L)
{
   lua_pushnumber(L,(int) retrace_count);
   return 1;
}

//------------------------------------------------------------------------------------------
//int install_timer();
static int l_install_timer(lua_State* L)
{
   lua_pushboolean(L,!(install_timer()));
   return 1;
}

//------------------------------------------------------------------------------------------
//void remove_timer();
static int l_remove_timer(lua_State* L)
{
   remove_timer();
   return 0;
}

//------------------------------------------------------------------------------------------
//int install_int(void (*proc)(), int speed);
//int install_int_ex(void (*proc)(), int speed);/
//void remove_int(void (*proc)());
//Functions above are very useful, I will eventually have to implement them somehow.

//------------------------------------------------------------------------------------------
static const struct luaL_reg allegro_time_lib [] = {
      {"rest",                   l_rest},
      {"retrace_count",          l_retrace_count},
      {"install_timer",          l_install_timer},
      {"remove_timer",           l_remove_timer},
      {NULL,                     NULL}  /* sentinel */
    };

//-----------------------------------------------------------------------------------------------
int luaopen_allegro_time(lua_State *L) 
{
   luaL_openlib(L, "allegro",   allegro_time_lib,   0);
   return 1;
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -