Xonotic
pong.qc
Go to the documentation of this file.
1 #include "pong.qh"
2 REGISTER_MINIGAME(pong, _("Pong"));
3 
4 // minigame flags
5 const int PONG_STATUS_WAIT = 0x0010; // waiting for players to join
6 const int PONG_STATUS_PLAY = 0x0020; // playing
7 
8 // send flags
9 // (minigame_player) sent when reporting scores
11 // (pong_ball) sent when changing team
13 
14 // keys
15 const int PONG_KEY_INCREASE = 0x01; // Move down/right
16 const int PONG_KEY_DECREASE = 0x02; // Move up/left
17 const int PONG_KEY_BOTH = 0x03; // Player jamming keys at ramdom
18 
19 // fields
20 const int PONG_MAX_PLAYERS = 4;
21 const int PONG_SPECTATOR_TEAM = 255; // must be above max teams and equal to or below 255
22 .int pong_score; // (minigame_player) number of goals
23 .int pong_keys; // (client) pressed keys
24 .entity pong_paddles[PONG_MAX_PLAYERS];// (minigame) paddles
25 .float pong_length; // (pong_paddle/pong_ball) size (0,1)
26 .entity pong_ai_paddle; // (pong_ai) controlled paddle entity
27 
28 #ifdef SVQC
29 
30 float autocvar_sv_minigames_pong_paddle_size;
31 float autocvar_sv_minigames_pong_paddle_speed;
32 
33 float autocvar_sv_minigames_pong_ball_wait;
34 float autocvar_sv_minigames_pong_ball_speed;
35 float autocvar_sv_minigames_pong_ball_radius;
36 float autocvar_sv_minigames_pong_ball_number;
37 
38 float autocvar_sv_minigames_pong_ai_thinkspeed;
39 float autocvar_sv_minigames_pong_ai_tolerance;
40 
41 void pong_ball_think(entity this);
42 
43 // Throws a ball in a random direction and sets the think function
44 void pong_ball_throw(entity ball)
45 {
46  float angle;
47  do
48  angle = random()*M_PI*2;
49  while ( fabs(sin(angle)) < 0.17 || fabs(cos(angle)) < 0.17 );
50  ball.velocity_x = cos(angle)*autocvar_sv_minigames_pong_ball_speed;
51  ball.velocity_y = sin(angle)*autocvar_sv_minigames_pong_ball_speed;
52  setthink(ball, pong_ball_think);
53  ball.nextthink = time;
54  ball.team = 0;
55  ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
56 }
57 
58 // Think equivalent of pong_ball_throw, used to delay throws
59 void pong_ball_throwthink(entity this)
60 {
61  pong_ball_throw(this);
62 }
63 
64 // Moves ball to the center and stops its motion
65 void pong_ball_reset(entity ball)
66 {
67  ball.velocity = '0 0 0';
68  ball.origin = '0.5 0.5 0';
69  setthink(ball, SUB_NullThink);
70  ball.team = 0;
71  ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
72  setthink(ball, pong_ball_throwthink);
73  ball.nextthink = time + autocvar_sv_minigames_pong_ball_wait;
74 }
75 
76 // Add the score to the given team in the minigame
77 void pong_add_score(entity minigame, int team_thrower, int team_receiver, int delta)
78 {
79  if ( !minigame )
80  return;
81 
82  if ( team_thrower == 0 )
83  team_thrower = team_receiver;
84 
85  if ( team_thrower == team_receiver )
86  delta *= -1;
87 
88  entity paddle_thrower = minigame.pong_paddles[team_thrower-1];
89  if ( paddle_thrower.realowner.minigame_players )
90  {
91  paddle_thrower.realowner.minigame_players.pong_score += delta;
92  paddle_thrower.realowner.minigame_players.SendFlags |= PONG_SF_PLAYERSCORE;
93  }
94 }
95 
96 // get point in the box nearest to the given one (2D)
97 vector box_nearest(vector box_min, vector box_max, vector p)
98 {
99  return vec2( p.x > box_max.x ? box_max.x : ( p.x < box_min.x ? box_min.x : p.x ),
100  p.y > box_max.y ? box_max.y : ( p.y < box_min.y ? box_min.y : p.y ) );
101 }
102 
103 void pong_paddle_bounce(entity ball, int pteam)
104 {
105  switch(pteam)
106  {
107  case 1: ball.velocity_x = -fabs(ball.velocity_x); break;
108  case 2: ball.velocity_x = fabs(ball.velocity_x); break;
109  case 3: ball.velocity_y = fabs(ball.velocity_y); break;
110  case 4: ball.velocity_y = -fabs(ball.velocity_y); break;
111  }
112 
113  float angle = atan2(ball.velocity_y, ball.velocity_x);
114  angle += ( random() - 0.5 ) * 2 * M_PI/6;
115  float speed = vlen(ball.velocity);
116 
117  ball.velocity_y = speed * sin(angle);
118  ball.velocity_x = speed * cos(angle);
119 }
120 
121 // checks if the ball hit the paddle for the given team
122 bool pong_paddle_hit(entity ball, int pteam)
123 {
124  entity paddle = ball.owner.pong_paddles[pteam-1];
125  if (!paddle)
126  return false;
127 
128 #if 1
129  vector near_point = box_nearest(paddle.m_mins+paddle.origin,
130  paddle.m_maxs+paddle.origin, ball.origin);
131  return vdist(near_point - ball.origin, <=, ball.pong_length);
132 #else
133  return boxesoverlap(paddle.m_mins + paddle.origin, paddle.m_maxs + paddle.origin, ball.m_mins + ball.origin, ball.m_maxs + ball.origin);
134 #endif
135 }
136 
137 // Checks for a goal, when that happes adds scores and resets the ball
138 bool pong_goal(entity ball, int pteam)
139 {
140  entity paddle = ball.owner.pong_paddles[pteam-1];
141  if (!paddle)
142  return false;
143 
144  if ( !pong_paddle_hit(ball, pteam) )
145  {
146  pong_add_score(ball.owner ,ball.team, pteam, 1);
147  pong_ball_reset(ball);
148  return true;
149  }
150 
151  return false;
152 }
153 
154 // Moves the ball around
155 void pong_ball_think(entity this)
156 {
157  float think_speed = autocvar_sys_ticrate;
158  this.nextthink = time + think_speed;
159 
160  this.origin_x += this.velocity_x * think_speed;
161  this.origin_y += this.velocity_y * think_speed;
162  this.SendFlags |= MINIG_SF_UPDATE;
163 
164  int i;
165  for ( i = 1; i <= PONG_MAX_PLAYERS; i++ )
166  if ( pong_paddle_hit(this, i) )
167  {
168  pong_paddle_bounce(this,i);
169  this.team = i;
170  this.SendFlags |= PONG_SF_BALLTEAM;
171  return;
172  }
173 
174  if ( this.origin_y <= this.pong_length )
175  {
176  if ( !pong_goal(this,3) )
177  {
178  this.origin_y = this.pong_length;
179  this.velocity_y *= -1;
180  }
181  }
182  else if ( this.origin_y >= 1-this.pong_length )
183  {
184  if ( !pong_goal(this,4) )
185  {
186  this.origin_y = 1-this.pong_length;
187  this.velocity_y *= -1;
188  }
189  }
190 
191  if ( this.origin_x <= this.pong_length )
192  {
193  if ( !pong_goal(this,2) )
194  {
195  this.origin_x = this.pong_length;
196  this.velocity_x *= -1;
197  }
198  }
199  else if ( this.origin_x >= 1-this.pong_length )
200  {
201  if ( !pong_goal(this,1) )
202  {
203  this.origin_x = 1-this.pong_length;
204  this.velocity_x *= -1;
205  }
206  }
207 
208 }
209 
210 // AI action
211 void pong_ai_think(entity this)
212 {
213  float think_speed = autocvar_sv_minigames_pong_ai_thinkspeed;
214  this.nextthink = time + think_speed;
215 
216  float distance;
217  float next_distance;
218  float min_distance = 1;
219  entity ball = NULL;
220  entity mayball = NULL;
221  while ( ( mayball = findentity(mayball,owner,this.owner) ) )
222  if ( mayball.classname == "pong_ball" )
223  {
224  distance = vlen(mayball.origin-this.pong_ai_paddle.origin);
225  next_distance = vlen(mayball.origin+mayball.velocity-this.pong_ai_paddle.origin);
226  if ( distance < min_distance && ( distance < 0.5 || next_distance < distance ) )
227  {
228  min_distance = distance;
229  ball = mayball;
230  }
231  }
232 
233  float target = 0.5;
234  float my_pos;
235 
236 
237  if ( this.team <= 2 )
238  {
239  if ( ball )
240  target = ball.origin_y + ball.velocity_y*think_speed;
241  my_pos = this.pong_ai_paddle.origin_y;
242  }
243  else
244  {
245  if ( ball )
246  target = ball.origin_x + ball.velocity_x*think_speed;
247  my_pos = this.pong_ai_paddle.origin_x;
248  }
249 
250  distance = this.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance
251  + autocvar_sv_minigames_pong_paddle_speed * think_speed;
252 
253  if (target < my_pos - distance)
255  else if (target > my_pos + distance)
257  else
258  this.pong_keys = 0;
259 }
260 
261 entity pong_ai_spawn(entity paddle)
262 {
263  entity ai = msle_spawn(paddle.owner,new(pong_ai));
264  ai.minigame_players = ai;
265  ai.team = paddle.team;
266  setthink(ai, pong_ai_think);
267  ai.nextthink = time;
268  ai.pong_ai_paddle = paddle;
269 
270  paddle.realowner = ai;
271 
272  return ai;
273 }
274 
275 // Moves the paddle
276 void pong_paddle_think(entity this)
277 {
278  float think_speed = autocvar_sys_ticrate;
279  this.nextthink = time + think_speed;
280 
281  if ( this.realowner.minigame_players.pong_keys == PONG_KEY_INCREASE ||
282  this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
283  {
284  float pmovement = autocvar_sv_minigames_pong_paddle_speed * think_speed;
285  float halflen = this.pong_length/2;
286 
287  if ( this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
288  pmovement *= -1;
289 
290  if ( this.team > 2 )
291  this.origin_x = bound(halflen, this.origin_x+pmovement, 1-halflen);
292  else
293  this.origin_y = bound(halflen, this.origin_y+pmovement, 1-halflen);
294 
295  this.SendFlags |= MINIG_SF_UPDATE;
296  }
297 }
298 
299 vector pong_team_to_box_halfsize(int nteam, float length, float width)
300 {
301  if ( nteam > 2 )
302  return vec2(length/2, width/2);
303  return vec2(width/2, length/2);
304 }
305 
306 vector pong_team_to_paddlepos(int nteam)
307 {
308  switch(nteam)
309  {
310  case 1: return '0.99 0.5 0';
311  case 2: return '0.01 0.5 0';
312  case 3: return '0.5 0.01 0';
313  case 4: return '0.5 0.99 0';
314  default:return '0 0 0';
315  }
316 }
317 
318 // Spawns a pong paddle
319 // if real_player is NULL, the paddle is controlled by AI
320 entity pong_paddle_spawn(entity minigame, int pl_team, entity real_player)
321 {
322  entity paddle = msle_spawn(minigame,new(pong_paddle));
323  paddle.pong_length = autocvar_sv_minigames_pong_paddle_size;
324  paddle.origin = pong_team_to_paddlepos(pl_team);
325  setthink(paddle, pong_paddle_think);
326  paddle.nextthink = time;
327  paddle.team = pl_team;
328  paddle.m_mins = pong_team_to_box_halfsize(pl_team,-paddle.pong_length,-1/16);
329  paddle.m_maxs = pong_team_to_box_halfsize(pl_team,paddle.pong_length,1/16);
330 
331  if ( real_player == NULL )
332  pong_ai_spawn(paddle);
333  else
334  paddle.realowner = real_player;
335 
336  minigame.pong_paddles[pl_team-1] = paddle;
337 
338  return paddle;
339 
340 }
341 
342 // required function, handle server side events
343 int pong_server_event(entity minigame, string event, ...)
344 {
345  switch (event)
346  {
347  case "start":
348  {
349  minigame.minigame_flags |= PONG_STATUS_WAIT;
350  return true;
351  }
352  case "join":
353  {
354  // Don't allow joining a match that is already running
355  if ( minigame.minigame_flags & PONG_STATUS_PLAY )
356  return PONG_SPECTATOR_TEAM;
357 
358  entity player = ...(0,entity);
359  int i;
360  for ( i = 0; i < PONG_MAX_PLAYERS; i++ )
361  {
362  if ( minigame.pong_paddles[i] == NULL )
363  {
364  pong_paddle_spawn(minigame,i+1,player);
365  return i+1;
366  }
367  }
368 
369  return PONG_SPECTATOR_TEAM;
370  }
371  case "part":
372  {
373  entity player = ...(0,entity);
374  entity paddle;
375  entity ai;
376  int i;
377  for ( i = 0; i < PONG_MAX_PLAYERS; i++ )
378  {
379  paddle = minigame.pong_paddles[i];
380  if ( paddle != NULL && paddle.realowner == player )
381  {
382  ai = pong_ai_spawn(paddle);
383  ai.pong_score = player.minigame_players.pong_score;
384  break;
385  }
386 
387  }
388  return false;
389  }
390  case "cmd":
391  {
392  entity player = ...(0,entity);
393  bool event_blocked = (player.team == PONG_SPECTATOR_TEAM);
394  switch(argv(0))
395  {
396  case "throw":
397  if(event_blocked)
398  return true;
399  if ( minigame.minigame_flags & PONG_STATUS_WAIT )
400  {
401  minigame.minigame_flags = PONG_STATUS_PLAY |
402  (minigame.minigame_flags & ~PONG_STATUS_WAIT);
403  minigame.SendFlags |= MINIG_SF_UPDATE;
404 
405  entity ball;
406  for ( int j = 0; j < autocvar_sv_minigames_pong_ball_number; j++ )
407  {
408  ball = msle_spawn(minigame,new(pong_ball));
409  ball.pong_length = autocvar_sv_minigames_pong_ball_radius;
410  ball.m_mins = vec2(-ball.pong_length, -ball.pong_length);
411  ball.m_maxs = vec2(ball.pong_length, ball.pong_length);
412  pong_ball_reset(ball);
413  }
414  }
415  return true;
416  case "+movei":
417  if(event_blocked)
418  return true;
419  player.pong_keys |= PONG_KEY_INCREASE;
420  return true;
421  case "+moved":
422  if(event_blocked)
423  return true;
424  player.pong_keys |= PONG_KEY_DECREASE;
425  return true;
426  case "-movei":
427  if(event_blocked)
428  return true;
429  player.pong_keys &= ~PONG_KEY_INCREASE;
430  return true;
431  case "-moved":
432  if(event_blocked)
433  return true;
434  player.pong_keys &= ~PONG_KEY_DECREASE;
435  return true;
436  case "move":
437  if(event_blocked)
438  return true;
439  if(argv(1))
440  player.pong_keys = stoi(argv(1));
441  return true;
442  case "pong_aimore":
443  {
444  if(event_blocked)
445  return true;
446  // keep declaration here, moving it into for() reverses weapon order
447  // potentially compiler bug
448  int j;
449  if ( minigame.minigame_flags & PONG_STATUS_WAIT )
450  for ( j = 0; j < PONG_MAX_PLAYERS; j++ )
451  //for ( int j = 0; j < PONG_MAX_PLAYERS; j++ )
452  {
453  if ( minigame.pong_paddles[j] == NULL )
454  {
455  pong_paddle_spawn(minigame,j+1,NULL);
456  return true;
457  }
458  }
459  sprint(player.minigame_players,"Cannot spawn AI\n");
460  return true;
461  }
462  case "pong_ailess":
463  {
464  if(event_blocked)
465  return true;
466  if ( minigame.minigame_flags & PONG_STATUS_WAIT )
467  {
468  entity paddle;
469  for ( int j = PONG_MAX_PLAYERS-1; j >= 0; j-- )
470  {
471  paddle = minigame.pong_paddles[j];
472  if ( paddle != NULL &&
473  paddle.realowner.classname == "pong_ai" )
474  {
475  minigame.pong_paddles[j] = NULL;
476  delete(paddle.realowner);
477  delete(paddle);
478  return true;
479  }
480  }
481  }
482  sprint(player.minigame_players,"Cannot remove AI\n");
483  return true;
484  }
485 
486  }
487  return false;
488  }
489  case "network_send":
490  {
491  entity sent = ...(0,entity);
492  int sf = ...(1,int);
493  if ( sent.classname == "minigame_player" && (sf & PONG_SF_PLAYERSCORE ) )
494  {
495  WriteLong(MSG_ENTITY,sent.pong_score);
496  }
497  return false;
498  }
499  }
500  return false;
501 }
502 
503 
504 #elif defined(CSQC)
505 
506 void drawrotpic(vector org, float rot, string pic, vector sz, vector hotspot, vector rgb, float a, float f);
507 
508 float pong_team_to_angle(int nteam)
509 {
510  switch(nteam)
511  {
512  default:
513  case 1: return 0;
514  case 2: return M_PI;
515  case 3: return M_PI*3/2;
516  case 4: return M_PI/2;
517  }
518 }
519 
520 vector pong_team_to_color(int nteam)
521 {
522  switch(nteam)
523  {
524  case 1: return '1 0 0';
525  case 2: return '0 0 1';
526  case 3: return '1 1 0';
527  case 4: return '1 0 1';
528  default:return '1 1 1';
529  }
530 }
531 
532 int pong_keys_pressed;
533 int pong_keys_pressed_old;
534 
535 // Required function, draw the game board
536 void pong_hud_board(vector pos, vector mySize)
537 {
538  if(pong_keys_pressed != pong_keys_pressed_old)
539  minigame_cmd(strcat("move ", itos(pong_keys_pressed)));
540  pong_keys_pressed_old = pong_keys_pressed;
541 
542  minigame_hud_fitsqare(pos, mySize);
543  minigame_hud_simpleboard(pos,mySize,minigame_texture("pong/board"));
544 
545  entity e;
546  vector obj_pos;
547  vector obj_size;
549  {
550  if ( e.classname == "pong_ball" )
551  {
552  // Note: 4*radius = 2*diameter because the image is large enough to fit the glow around the ball
553  obj_size = minigame_hud_denormalize_size('4 4 0'*e.pong_length,pos,mySize);
554  obj_pos = minigame_hud_denormalize(e.origin,pos,mySize);
555 
556  minigame_drawpic_centered( obj_pos, minigame_texture("pong/ball"),
557  obj_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL );
558 
559  minigame_drawpic_centered( obj_pos, minigame_texture("pong/ball-glow"),
560  obj_size, pong_team_to_color(e.team),
562  }
563  else if ( e.classname == "pong_paddle" )
564  {
565  obj_pos = minigame_hud_denormalize(e.origin,pos,mySize);
566  obj_size = minigame_hud_denormalize_size(eX / 16 + eY*e.pong_length,pos,mySize);
567 
568  drawrotpic(obj_pos, pong_team_to_angle(e.team), minigame_texture("pong/paddle-glow"),
569  obj_size, obj_size/2, pong_team_to_color(e.team),
571 
572  drawrotpic(obj_pos, pong_team_to_angle(e.team), minigame_texture("pong/paddle"),
573  obj_size, obj_size/2, '1 1 1',
575 
576  }
577  }
578 }
579 
580 // Required function, draw the game status panel
581 void pong_hud_status(vector pos, vector mySize)
582 {
584  vector ts;
585  ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
586  hud_fontsize * 2, '0.25 0.47 0.72', panel_fg_alpha, DRAWFLAG_NORMAL,0.5);
587  ts_y += hud_fontsize_y;
588  pos_y += ts_y;
589  mySize_y -= ts_y;
590 
591  vector player_fontsize = hud_fontsize * 1.75;
592  ts_y = ( mySize_y - PONG_MAX_PLAYERS*player_fontsize_y ) / PONG_MAX_PLAYERS;
593  ts_x = mySize_x;
594  vector mypos;
595 
596  entity e;
598  {
599  if ( (e.classname == "minigame_player" || e.classname == "pong_ai") && e.team != PONG_SPECTATOR_TEAM )
600  {
601  mypos = pos;
602  mypos_y += (e.team-1) * (player_fontsize_y + ts_y);
603 
604  drawfill(mypos, ts, pong_team_to_color(e.team), 0.25, DRAWFLAG_ADDITIVE);
605 
607  (e.minigame_playerslot ? entcs_GetName(e.minigame_playerslot-1) : _("AI")),
608  player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
609 
610  drawstring(mypos+eY*player_fontsize_y,ftos(e.pong_score),'48 48 0',
611  '0.7 0.84 1', panel_fg_alpha, DRAWFLAG_NORMAL);
612 
613  if ( e == minigame_self )
614  drawborderlines(1, mypos, ts, pong_team_to_color(e.team), 1, DRAWFLAG_NORMAL);
615  }
616  }
617 }
618 
619 // convert minigame flags to a message
620 string pong_message(int mgflags)
621 {
622  string rmessage = "";
623  if(minigame_self.team == PONG_SPECTATOR_TEAM)
624  rmessage = _("You are spectating");
625  else if (mgflags & PONG_STATUS_WAIT)
626  rmessage = _("Press ^1Start Match^7 to start the match with the current players");
627  return rmessage;
628 }
629 
630 // Required function, handle client events
631 int pong_client_event(entity minigame, string event, ...)
632 {
633  switch(event)
634  {
635  case "activate":
636  return false;
637  case "deactivate":
638  {
639  strfree(minigame.message);
640  return false;
641  }
642  case "key_pressed":
643  case "key_released":
644  if ((minigame.minigame_flags & PONG_STATUS_PLAY) && minigame_self.team != PONG_SPECTATOR_TEAM)
645  switch ( ...(0,int) )
646  {
647  case K_UPARROW:
648  case K_KP_UPARROW:
649  case K_LEFTARROW:
650  case K_KP_LEFTARROW:
651  if (event == "key_pressed")
652  {
653  //minigame_cmd("+moved");
654  pong_keys_pressed |= PONG_KEY_DECREASE;
655  }
656  else
657  {
658  //minigame_cmd("-moved");
659  pong_keys_pressed &= ~PONG_KEY_DECREASE;
660  }
661  return true;
662  case K_DOWNARROW:
663  case K_KP_DOWNARROW:
664  case K_RIGHTARROW:
665  case K_KP_RIGHTARROW:
666  if (event == "key_pressed")
667  {
668  //minigame_cmd("+movei");
669  pong_keys_pressed |= PONG_KEY_INCREASE;
670  }
671  else
672  {
673  //minigame_cmd("-movei");
674  pong_keys_pressed &= ~PONG_KEY_INCREASE;
675  }
676  return true;
677  }
678  return false;
679  case "network_receive":
680  {
681  entity sent = ...(0,entity);
682  int sf = ...(1,int);
683  if ( sent.classname == "minigame_player" && (sf & PONG_SF_PLAYERSCORE ) )
684  {
685  sent.pong_score = ReadLong();
686  }
687  else if ( sent.classname == "minigame" )
688  {
689  if ( sf & MINIG_SF_UPDATE )
690  {
691  strcpy(sent.message, pong_message(sent.minigame_flags));
692  }
693  }
694  return false;
695  }
696  case "menu_show":
697  {
698  HUD_MinigameMenu_CustomEntry(...(0,entity),_("Start Match"),"pong_throw");
699  HUD_MinigameMenu_CustomEntry(...(0,entity),_("Add AI player"),"pong_aimore");
700  HUD_MinigameMenu_CustomEntry(...(0,entity),_("Remove AI player"),"pong_ailess");
701  return false;
702  }
703  case "menu_click":
704  {
705  string cmd = ...(0,string);
706  if( cmd == "pong_throw" && minigame.minigame_flags & PONG_STATUS_WAIT )
707  {
708  minigame_cmd("throw");
709  }
710  else if ( cmd == "pong_aimore" || cmd == "pong_ailess" )
711  {
712  minigame_cmd(cmd);
713  }
714  return false;
715  }
716  }
717 
718  return false;
719 }
720 #endif
float K_KP_RIGHTARROW
Definition: keycodes.qc:60
float K_UPARROW
Definition: keycodes.qc:15
void HUD_MinigameMenu_CustomEntry(entity parent, string menumessage, string event_arg)
float panel_fg_alpha
Definition: hud.qh:166
float speed
Definition: subs.qh:41
#define int
Definition: _all.inc:20
#define FOREACH_MINIGAME_ENTITY(entityvar)
Definition: cl_minigames.qh:98
const vector eY
Definition: vector.qh:45
vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize)
Definition: cl_minigames.qc:23
float pong_length
Definition: pong.qc:25
float K_DOWNARROW
Definition: keycodes.qc:16
int team
Definition: main.qh:157
#define minigame_hud_fitsqare(pos, mySize)
Definition: cl_minigames.qh:7
entity msle_spawn(entity minigame_session, entity e)
Definition: minigames.qc:87
float K_KP_DOWNARROW
Definition: keycodes.qc:53
entity() spawn
float autocvar_sys_ticrate
Definition: main.qh:17
const int PONG_STATUS_PLAY
Definition: pong.qc:6
string() ReadString_Raw
const int PONG_STATUS_WAIT
Definition: pong.qc:5
const int PONG_SPECTATOR_TEAM
Definition: pong.qc:21
#define itos(i)
Definition: int.qh:6
float K_RIGHTARROW
Definition: keycodes.qc:18
const int MINIG_SF_UPDATE
Definition: minigames.qh:109
entity owner
Definition: main.qh:73
int pong_keys
Definition: pong.qc:23
#define strcpy(this, s)
Definition: string.qh:49
const int PONG_MAX_PLAYERS
Definition: pong.qc:20
#define stoi(s)
Definition: int.qh:4
const float DRAWFLAG_ADDITIVE
Definition: csprogsdefs.qc:318
const int PONG_KEY_BOTH
Definition: pong.qc:17
const int MINIG_SF_CUSTOM
Definition: minigames.qh:110
#define HUD_Panel_DrawBg()
Definition: hud.qh:54
void minigame_drawpic_centered(vector pos, string texture, vector sz, vector color, float thealpha, int drawflags)
string minigame_texture(string name)
Definition: cl_minigames.qc:49
REGISTER_MINIGAME(pong, _("Pong"))
entity active_minigame
Definition: cl_minigames.qh:85
ERASEABLE float boxesoverlap(vector m1, vector m2, vector m3, vector m4)
requires that m2>m1 in all coordinates, and that m4>m3
Definition: vector.qh:73
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
#define minigame_cmd(...)
Definition: cl_minigames.qh:90
float nextthink
Definition: csprogsdefs.qc:121
const int PONG_KEY_INCREASE
Definition: pong.qc:15
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void SUB_NullThink(entity this)
Definition: subs.qc:3
const float M_PI
Definition: csprogsdefs.qc:269
const vector eX
Definition: vector.qh:44
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
vector minigame_hud_denormalize(vector v, vector pos, vector mySize)
Definition: cl_minigames.qc:16
void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag)
Definition: draw.qc:5
const int PONG_SF_BALLTEAM
Definition: pong.qc:12
entity realowner
Definition: common.qh:25
#define vec2(...)
Definition: vector.qh:90
float K_LEFTARROW
Definition: keycodes.qc:17
void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags)
const int PONG_KEY_DECREASE
Definition: pong.qc:16
vector hud_fontsize
Definition: main.qh:63
entity pong_ai_paddle
Definition: pong.qc:26
#define setthink(e, f)
#define strfree(this)
Definition: string.qh:56
void minigame_hud_simpleboard(vector pos, vector mySize, string board_texture)
Definition: cl_minigames.qc:4
string target
Definition: progsdefs.qc:193
int pong_score
Definition: pong.qc:22
entity minigame_self
Definition: cl_minigames.qh:87
const int PONG_SF_PLAYERSCORE
Definition: pong.qc:10
float time
Definition: csprogsdefs.qc:16
float K_KP_LEFTARROW
Definition: keycodes.qc:57
float K_KP_UPARROW
Definition: keycodes.qc:64
entity pong_paddles[PONG_MAX_PLAYERS]
Definition: pong.qc:24
vector minigame_drawstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags, float align)