Subversion Repositories DIN Is Noise

Rev

Rev 2302 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1528 jag 1
/*
2
* ball.h
3
* ball in Mondrian
1713 jag 4
* DIN Is Noise is released under GNU Public License 2.0
2302 jag 5
* DIN Is Noise is copyright (c) 2006-2025 Jagannathan Sampath
1528 jag 6
* For more information, please visit https://dinisnoise.org/
7
*/
8
 
9
#ifndef __ball__
10
#define __ball__
11
 
12
#include "trail.h"
13
#include "ball_ops.h"
14
 
15
struct rect;
16
 
17
struct ball { // a ball
18
 
19
  enum {NOTE = 0, NOISE};
20
  int trig_what; // trigger note or noise?
1994 jag 21
  static const char* trigstr [2];
1528 jag 22
 
23
  float x, y; // position
24
 
25
  // velocity - speed, vector, slope, slope inverse, is slope infinite?
26
  float V, vx, vy, vm, vm_1;
27
  int vm_inf;
28
 
29
  int auto_rotate; // velocity vector auto rotating? 0 - no, 1 - anti-clockwise, -1 - clockwise
30
  float dtheta; // angle to rotate ball direction
31
 
32
  rect* R; // box in which it is bouncing
33
  int select; // selected?
34
  int frozen; // frozen?
35
 
36
  float pitch_mult; // to modulate pitch
37
  int mod; // 0 = no modulation, < 0 = modulate down, > 0 modulate up // for visual
38
 
39
  float vol_mult; // to scale triggered sound volume
40
  float attack_time; // time for note to rise to full volume
41
  float decay_time; // time for note to fall silent
42
  enum {SET_DECAY_TIME=1, SET_ATTACK_TIME, SET_VOL_MULT};
43
 
44
  // bouncer = bounces, wrecker = makes slits, healer = closes slits
45
  int type;
46
  static const char* types_str [4];
47
  enum {BOUNCER=0, WRECKER, HEALER, INVALID};  // ball types
48
 
49
  // to initialise new ball
50
  static float recent_attack_time;
51
  static float recent_decay_time;
52
  static float recent_pitch_mult;
53
 
54
  int num_notes; // number of active notes triggered by this ball
55
  int del; // delete ball? when triggered sounds have decayed
56
 
57
  // operations
58
  turn op_turn;
59
  speed op_speed;
60
  teleport op_teleport;
61
  Clone op_clone;
62
  Transform op_transform;
63
 
64
  void eval_ops ();
65
 
66
  // visual
67
  trail_t trail; // trail
68
  float r, g, b; // color
69
 
70
  // log
71
  static int ref; // to log if we deleted all balls on exit
72
 
73
  ball (int _type = BOUNCER);
74
  ~ball () { --ref; }
75
 
76
  void init (int _type = BOUNCER);
77
  void set_velocity (float _x, float _y);
78
  void rotate_velocity (int dir);
79
  void calc_velocity_slope ();
80
  void update ();
81
  void set_type (int _type);
82
  void color_using_modulation ();
83
  void on_edge_hit (int e1, int e2, int cl, float& v, float xry, float yrx, float elb, float ewh, std::pair<float, float>& invl, int& eh);
84
  void print ();
85
  void clone_this (ball* C);
86
 
2308 jag 87
  // binaurality
88
  int binaural;
89
  int just;
90
  float sep; // in hz 
91
 
1528 jag 92
};
93
#endif