int cd_current_track(void) { unsigned long loc; short i; if (!audio_busy() || !get_audio_info()) return 0; loc = head_position(); for (i = cdrom_data.high_audio; i > cdrom_data.low_audio; i--) { set_track(i); if (loc > cdrom_data.track_position) return i; } return cdrom_data.low_audio; }
Crocodile::Crocodile(Engine& engine): Listener<UpdateEvent>(engine.state.updateListeners), Listener<RenderEvent>(engine.state.renderListeners), direction(1,0), speed(0.0002), gfxNose(engine.resources.get<sf::Texture>("gfx/nose.png")), gfxHead(engine.resources.get<sf::Texture>("gfx/head.png")), gfxBody(engine.resources.get<sf::Texture>("gfx/body.png")) { sprites.resize(initial_length); // create the nose sf::Sprite& nose = sprites[0]; nose.setOrigin(60, 60); nose.setTexture(*gfxNose); nose.setPosition(sf::Vector2f(60.0, 60.0)); // create the head sf::Sprite& head = sprites[1]; head.setOrigin(60, 60); head.setTexture(*gfxHead); head.setPosition(sf::Vector2f(80.0, 60.0)); // create the body // start at 2 to compensate for the nose and head for (int i = 2; i < initial_length; ++i) { sf::Sprite& body = sprites[i]; body.setOrigin(60, 60); body.setTexture(*gfxBody); body.setPosition(sf::Vector2f(60 + 60*i, 0)); } // record first path chunk sf::Vector2f head_position(200.0, 200.0); float snake_length = dist_between_sprites * initial_length; sf::Vector2f tail_position = head_position - (direction * snake_length); PathChunk straight_line; straight_line.from = direction; straight_line.to = direction; straight_line.length = snake_length; straight_line.position = tail_position; path.push_front(straight_line); }