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

📄 billard3d.c

📁 这是一个相当棒的Linux下的台球游戏
💻 C
📖 第 1 页 / 共 5 页
字号:
/* billard3d.c****    drawing all with OpenGL**    Copyright (C) 2001  Florian Berger**    Email: harpin_floh@yahoo.de, florian.berger@jk.uni-linz.ac.at****    This program is free software; you can redistribute it and/or modify**    it under the terms of the GNU General Public License Version 2 as**    published by the Free Software Foundation;****    This program is distributed in the hope that it will be useful,**    but WITHOUT ANY WARRANTY; without even the implied warranty of**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the**    GNU General Public License for more details.****    You should have received a copy of the GNU General Public License**    along with this program; if not, write to the Free Software**    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.***/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <unistd.h>#include <endian.h>#ifndef USE_SDL#include <GL/glut.h>#else#include <GL/glu.h>#include <GL/gl.h>#endif//#include <sys/timeb.h>  /* my_time */#ifndef _WIN32   #include <sys/time.h>    // us time measure   #include <getopt.h>#else   #include <sys/timeb.h>   // us time measure#endif#include "billard.h"#include "ball.h"#include "table.h"#include "queue.h"#include "png_loader.h"#include "aiplayer.h"#include "options.h"#include "player.h"#include "evaluate_move.h"#include "helpscreen.h"#ifdef options_use_freetype#include "font.h"#include "textobj.h"#endif#ifdef XMESA#include <GL/xmesa.h>#endif#include "sys_stuff.h"#include "net_socket.h"#include "sound_stuff.h"#include "menu.h"#include "gamemenu.h"#define LIT 1#define TEXTURED 2#define REFLECT 3#define ANIMATE 10#define POINT_FILTER 20#define LINEAR_FILTER 21#define QUIT 100#define CUE_BALL_IND (player[act_player].cue_ball)#define CUE_BALL_POS (balls.ball[CUE_BALL_IND].r)#define CUE_BALL_XYPOS (vec_xyz(CUE_BALL_POS.x,CUE_BALL_POS.y,0.0))#define CUEBALL_MAXSPEED 7.0//#define strcpy_whtspace_2_uscore(dst,src) {int _i_; for(_i_=0;(dst[_i_]=src[_i_])!=0;_i_++) if(dst[_i_]==' ') dst[_i_]='_';}//#define strcpy_uscore_2_whtspace(dst,src) {int _i_; for(_i_=0;(dst[_i_]=src[_i_])!=0;_i_++) if(dst[_i_]=='_') dst[_i_]=' ';}#define strcpy_uscore_2_whtspace(d,s) {int i; for(i=0;(d[i]=(s[i]!='_'?s[i]:' '))!=0;i++);}#define strcpy_whtspace_2_uscore(d,s) {int i; for(i=0;(d[i]=(s[i]!=' '?s[i]:'_'))!=0;i++);}/* control-flags */int control__updated=0;  /* just activated */int control__active=0;   /* one conrol is active *//* the controls */int control__english=0;int control__cue_butt_updown=0;int control__mouse_shoot=0;int control__place_cue_ball=0;//#define WIDTH   1280//#define HEIGHT  1024//#define WIDTH   1024//#define HEIGHT   768int win_width = 800;int win_height = 600;//int win_width = 1024;//int win_height = 768;#define WIDTH    win_width#define HEIGHT   win_height//#define TIME_INTERPOLATEdouble scr_dpi = 80.0;BallsType balls;BallsType bakballs;BordersType walls;static int frametime_ms_min = 10;static int frametime_ms_max = 200;static int frametime_ms = 40;static int fullscreen=0;  /* this is not updated during runtime - its only for startup */static GLuint table_obj = 0;static GLboolean Animate = GL_TRUE;static GLfloat Xrot = -70.0, Yrot = 0.0, Zrot = 0.0;static GLfloat Xque = -83.0, Zque = 0.0;static GLfloat Xrot_offs=0.0, Yrot_offs=0.0, Zrot_offs=0.0;static GLfloat scale = 1.0;int b1_hold = 0;int start_x, start_y;int mouse_moved_after_b1_dn = 0;int b2_hold = 0;int scaling_start, scaling_start2;int b2_b1_hold = 0;GLfloat cam_dist_aim = 2.5;GLfloat cam_dist;GLfloat cam_FOV=40.0;VMvect  free_view_pos_aim;VMvect  free_view_pos;#define FREE_VIEW  ((!queue_view) && options_free_view_on)static int  vline_on=1;//static int  key_modifiers;static int  queue_view=1;static int  old_queue_view=1;static double queue_anim=0.0;static GLfloat queue_offs=0.06;#define queue_point_x  (player[act_player].cue_x)#define queue_point_y  (player[act_player].cue_y)#define queue_strength (player[act_player].strength)static int  balls_moving=0;/* reflection map */static int    spheretexw,spheretexh;static char * spheretexdata;static GLuint spheretexbind;static char * lightspheretexdata;static GLuint lightspheretexbind;static GLuint reftexbind;static GLuint placecueballtexbind;static GLuint blendetexbind;static GLuint lightflaretexbind;static GLuint halfsymboltexbind;static GLuint fullsymboltexbind;static GLuint fullhalfsymboltexbind;static GLuint fblogotexbind;static int  show_fps=0;static int  helpscreen_on=0;/* cubemap reflection stuff *///#define MAX_BALLS 22//static int   cuberef_res=128;#define cuberef_res options_cuberef_res//static int   cubereftexbind=0;static int   cuberef_allballs_texbind_nr = 0;static int * cuberef_allballs_texbind = 0;VMvect comp_dir;static int  human_human_mode=0;static int  act_player=0;   /* 0 or 1 */static char * player_names[]={"Human Player","AI Player","Human Player 2","AI Player 2"};static char * half_full_names[]={"any","full","half"};static int  b1_b2_hold=0;/*static struct Player{    int is_AI;    int half_full;    int queue_view;    double Zque;    double Xque;    double cue_x;    double cue_y;    double strength;    char *name;} player[2];*/static struct Player player[2];VMvect lightpos[10];int    lightnr=3;enum gameType gametype = GAME_8BALL;static int  g_socket=0;static int  g_network_play=0;static int  g_is_host=0;//static int  g_lookballnr;static menuType  * g_act_menu;static menuType  * g_main_menu;static menuType  * g_options_menu;static int menu_on=0;int   g_shot_due=1;  /* a shot to be due at the beginning */float g_motion_ratio=1.0;  /* a shot to be due at the beginning */typedef enum{  NET_STATE_REQ,  NET_STATE_ACK,  NET_STATE_DATA} NetState;NetState g_net_state=NET_STATE_REQ;typedef struct{    double Xrot;    double Zrot;    double white_x;    double white_y;    double cue_x;    double cue_y;    double strength;    int    shoot;} NetData;NetData g_net_data;//#define Xque (player[act_player].X_que)//#define Zque (player[act_player].Z_que)//#define queue_view (player[act_player].queueview)#ifdef USE_SOUNDstatic TSound ball_ball_snd;static TSound ball_wall_snd;static TSound ball_cue_snd;#define SOUND_NULLOFFS 10000#endif/*#define TIME_INTERPOLATE*/#ifdef TIME_INTERPOLATEint g_frametime_laststep;int g_frametime_fromlast;BallsType g_lastballs;BallsType g_drawballs;#endif#define ROSTER_MAX_NUM 128struct PlayerRoster{    int             nr;       /* number of players */    struct Player   player[ROSTER_MAX_NUM];   /* players */} human_player_roster;#define TOURNAMENT_ROUND_NUM 4static struct TournamentState_ {    int round_num;    int game_ind;    int round_ind;    int wait_for_next_match; /* show status meanwhile */    int wait_for_next_round; /* show status meanwhile */    int overall_winner;    int tournament_over;    double ai_fast_motion;    struct {        int roster_player1;        int roster_player2;        int winner;    } game[TOURNAMENT_ROUND_NUM/*rounds*/][1<<(TOURNAMENT_ROUND_NUM-1)/*games*/];    struct PlayerRoster roster;} tournament_state;static textObj * winner_name_text_obj;static textObj * winner_text_obj;#ifndef _WIN32enum optionType{    OPT_PLAYER1,    OPT_PLAYER2,    OPT_NAME1,    OPT_NAME2,    OPT_HELP,    OPT_8BALL,    OPT_9BALL,    OPT_CARAMBOL,    OPT_SNOOKER,    OPT_TABLECOL,    OPT_EDGECOL,    OPT_FRAMECOL,    OPT_CHROMEBLUE,    OPT_GOLDGREEN,    OPT_GOLDRED,    OPT_BLACKWHITE,    OPT_BLACKBEIGE,    OPT_TABLESIZE,    OPT_LENSFLARE,    OPT_NOLENSFLARE,    OPT_POSLIGHT,    OPT_DIRLIGHT,    OPT_AI1ERR,    OPT_AI2ERR,    OPT_BALLDETAIL,    OPT_RGSTEREO,    OPT_RGAIM,/*    OPT_NETGAME,    OPT_HOST,*/    OPT_HOSTADDR,    OPT_PORTNUM,

⌨️ 快捷键说明

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