Do powerup sparkles and stuff
| 1850 | |
| 1851 | // Do powerup sparkles and stuff |
| 1852 | void DrawPowerupSparkles(object *obj) { |
| 1853 | extern bool Render_mirror_for_room; |
| 1854 | if (!Render_powerup_sparkles) |
| 1855 | return; |
| 1856 | |
| 1857 | if (Game_paused) |
| 1858 | return; |
| 1859 | |
| 1860 | // we want to render if |
| 1861 | // a) we are not rendering in a mirror |
| 1862 | // b) we are rendering a mirror but the object is not visible from our position |
| 1863 | if (Render_mirror_for_room && !IsPointVisible(&obj->pos, obj->size, NULL)) |
| 1864 | return; |
| 1865 | |
| 1866 | if (obj->render_type != RT_POLYOBJ) |
| 1867 | return; |
| 1868 | |
| 1869 | // check to see if it's time to update |
| 1870 | if (Last_powerup_sparkle_time < POWERUP_SPARKLE_INTERVAL) |
| 1871 | return; |
| 1872 | |
| 1873 | int num_sparks = ps_rand() & 7; |
| 1874 | float obj_size_delta = obj->size * 0.3f; |
| 1875 | |
| 1876 | // Create some sparks |
| 1877 | for (int i = 0; i < num_sparks; ++i) { |
| 1878 | const int randnum = ps_rand() % 10; |
| 1879 | |
| 1880 | int index; |
| 1881 | switch (randnum) { |
| 1882 | case 0: |
| 1883 | index = HOT_SPARK_INDEX; |
| 1884 | break; |
| 1885 | case 1: |
| 1886 | index = COOL_SPARK_INDEX; |
| 1887 | break; |
| 1888 | default: |
| 1889 | index = GRAY_SPARK_INDEX; |
| 1890 | break; |
| 1891 | } |
| 1892 | |
| 1893 | vector pos_delta; |
| 1894 | pos_delta.x = (ps_rand() % 100) - 50; |
| 1895 | pos_delta.y = (ps_rand() % 100) - 80; |
| 1896 | pos_delta.z = (ps_rand() % 100) - 50; |
| 1897 | vm_NormalizeVector(&pos_delta); |
| 1898 | pos_delta = obj->last_pos + (obj_size_delta * pos_delta); |
| 1899 | |
| 1900 | int sparknum = VisEffectCreate(VIS_FIREBALL, index, obj->roomnum, &pos_delta); |
| 1901 | if (sparknum >= 0) { |
| 1902 | vis_effect *vis = &VisEffects[sparknum]; |
| 1903 | |
| 1904 | vis->end_pos = vis->pos; |
| 1905 | vis->movement_type = MT_PHYSICS; |
| 1906 | vis->mass = 1000.0f; |
| 1907 | vis->drag = 0.2f; |
| 1908 | vis->phys_flags |= PF_GRAVITY | PF_NO_COLLIDE; |
| 1909 |
no test coverage detected