Exemplo n.º 1
0
void
ejoy2d_win_init(int argc, char *argv[]) {
	G = create_game();
	lua_State *L = ejoy2d_game_lua(G->game);
	lua_pushcfunction(L, traceback);
	int tb = lua_gettop(L);
	int err = luaL_loadstring(L, startscript);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}
  
  lua_pushstring(L, "./");
  lua_pushstring(L, "examples/ex03.lua");
  
	err = lua_pcall(L, 2, 0, tb);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}

	lua_pop(L,1);

	screen_init(WIDTH,HEIGHT,1.0f);
	ejoy2d_game_start(G->game);
}
Exemplo n.º 2
0
void
ejoy2d_win_init(int orix, int oriy, int width, int height, float scale, const char* folder) {
	G = create_game();
	lua_State *L = ejoy2d_game_lua(G->game);
	lua_pushcfunction(L, traceback);
	int tb = lua_gettop(L);
	int err = luaL_loadstring(L, startscript);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}

  lua_pushstring(L, folder);
  lua_pushstring(L, "examples/ex03.lua");

	err = lua_pcall(L, 2, 0, tb);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}

	lua_pop(L,1);

	screen_init(width,height,scale);
	ejoy2d_game_start(G->game);
}
Exemplo n.º 3
0
Arquivo: winfw.c Projeto: ywxzm/ejoy2d
void
ejoy2d_win_init(int argc, char *argv[]) {
	G = create_game();
	screen_init(WIDTH,HEIGHT,1.0f);
	lua_State *L = ejoy2d_game_lua(G->game);
	lua_pushcfunction(L, traceback);
	int tb = lua_gettop(L);
	int err = luaL_loadstring(L, startscript);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}

	char modname[1024];

	int sz = GetModuleFileNameA(0,  modname, 1024);

	lua_pushlstring(L, modname, sz);

	int i;
	for (i=1;i<argc;i++) {
		lua_pushstring(L, argv[i]);
	}

	err = lua_pcall(L, argc, 0, tb);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}

	lua_pop(L,1);

	ejoy2d_game_start(G->game);
}
Exemplo n.º 4
0
void
ejoy2d_win_init(int argc, char *argv[]) {
	G = create_game();
	lua_State *L = ejoy2d_game_lua(G->game);
    int top = lua_gettop(L);
    luaL_requiref(L, "socket.c", luaopen_socket_c, 0);
    luaL_requiref(L, "socketbuffer.c", luaopen_socketbuffer_c, 0);
    luaL_requiref(L, "audio.c", luaopen_audio_c, 0);
    luaL_requiref(L, "png", luaopen_png, 0);
    lua_settop(L, top);

    lua_pushcfunction(L, traceback);
	int tb = lua_gettop(L);

    char buf[BUFSIZE];
    const char *pathbuf = read_exepath(buf, BUFSIZE);
    if (pathbuf == NULL)
        fault("can't read exepath");

	int err = luaL_loadstring(L, startscript);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}

    lua_pushstring(L, pathbuf);
	int i;
	for (i=1;i<argc;i++) {
		lua_pushstring(L, argv[i]);
	}
    screen_init(WIDTH,HEIGHT,1.0f);
	err = lua_pcall(L, argc, 0, tb);
	if (err) {
		const char *msg = lua_tostring(L,-1);
		fault("%s", msg);
	}

	lua_pop(L,1);	
	ejoy2d_game_start(G->game);
}