1 /* 2 * GRacer 3 * 4 * Copyright (C) 1999 Takashi Matsuda <matsu@users.sourceforge.net> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 * USA 20 */ 21 22 #ifndef __GRACER_WORLD_H__ 23 #define __GRACER_WORLD_H__ 24 25 #include "vehicle.h" 26 27 typedef struct GrWorld GrWorld; 28 typedef struct GrTrigger GrTrigger; 29 30 typedef enum { 31 GR_TRIGGER_LAP = 1 << 8, 32 GR_TRIGGER_SPEED_LT = 1 << 9, 33 GR_TRIGGER_SPEED_GT = 1 << 10, 34 GR_TRIGGER_RPM_LT = 1 << 11, 35 GR_TRIGGER_RPM_GT = 1 << 12, 36 GR_TRIGGER_VEHICLE = 1 << 13, 37 GR_TRIGGER_CLINE = 1 << 14, 38 GR_TRIGGER_LAP_PLUS = 1 << 15, 39 } GrTriggerCondition; 40 41 typedef void (* GrTriggerFunc) (GrWorld *world, 42 GrVehicle *vehicle, 43 GrTrigger *trigger); 44 45 struct GrTrigger { 46 GrRef ref; 47 48 GrVehicle *vehicle; 49 GrTriggerFunc callback; 50 51 GrTriggerCondition condition; 52 int cline; 53 int lap; 54 double speed_lt, speed_gt; 55 double rpm_lt, rpm_gt; 56 }; 57 58 struct GrWorld { 59 GrRef ref; 60 61 GrCourse *course_data; 62 GrSList *vehicles; 63 GrSList *triggers; 64 65 double minimam_interval; 66 67 double current_time; 68 double previous_time; 69 }; 70 71 GrWorld* gr_world_new (void); 72 73 void gr_world_set_course (GrWorld *world, GrCourse *course); 74 void gr_world_add_vehicle (GrWorld *world, GrVehicle *vehicle); 75 void gr_world_remove_vehicle (GrWorld *world, GrVehicle *vehicle); 76 77 void gr_world_add_trigger (GrWorld *world, GrTrigger *trigger); 78 void gr_world_remove_trigger (GrWorld *world, GrTrigger *trigger); 79 void gr_world_remove_triggers_of_vehicle 80 (GrWorld *world, GrVehicle *vehicle); 81 void gr_world_remove_triggers (GrWorld *world); 82 83 void gr_world_do_simulate (GrWorld *world, double interval); 84 85 #endif /* __GRACER_WORLD_H__ */ 86