This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48f98e3
commit 1defd86
Showing
134 changed files
with
278 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
You are free to do anything with these graphics beside selling them. Using them for commercial projects is fine. | ||
|
||
Note that I'm far from being an artist and these graphics are primarily meant as placeholders. | ||
|
||
Not all spaceships are available in all sizes. | ||
|
||
Dave Toulouse | ||
www.over00.com |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
use std::f32::consts::PI; | ||
use entities::Bullet; | ||
use GraphicsEnum; | ||
use engine::*; | ||
|
||
pub struct Enemy1 { | ||
start_x: f32, | ||
start_y: f32, | ||
health: f32, | ||
diagonal_direction: f32, | ||
bullet_target_time: f32, | ||
bullet_recharge_counter: f32, | ||
} | ||
|
||
const ONETHIRD: f32 = 1f32 / 3f32; | ||
const TWOTHIRD: f32 = ONETHIRD * 2f32; | ||
|
||
impl Enemy1 { | ||
pub fn new(x: f32, y: f32, factor: f32) -> Enemy1 { | ||
let bullet_target_time = 5000f32 / (factor / 2f32); | ||
Enemy1 { | ||
start_x: x, | ||
start_y: y, | ||
health: factor / 5f32, | ||
diagonal_direction: 0f32, | ||
bullet_target_time: bullet_target_time, | ||
bullet_recharge_counter: bullet_target_time / 2f32, | ||
} | ||
} | ||
} | ||
|
||
impl EntityTrait<GraphicsEnum> for Enemy1 { | ||
fn identifying_string(&self) -> String { | ||
"Enemy type 1".to_owned() | ||
} | ||
fn collision_layers(&self) -> Option<CollisionLayer> { | ||
Some(CollisionLayer::Enemy) | ||
} | ||
fn collides_with_layers(&self) -> Vec<CollisionLayer> { | ||
vec![CollisionLayer::Player] | ||
} | ||
fn get_initial_state(&mut self, engine: &Engine<GraphicsEnum>) -> EntityState { | ||
let hitbox = Hitbox { | ||
left: 25f32, | ||
top: 40f32, | ||
right: 25f32, | ||
bottom: 40f32, | ||
}; | ||
self.diagonal_direction = if self.start_y > engine.graphics.height / 2f32 { -1f32 } else { 1f32 }; | ||
EntityState { | ||
x: self.start_x, | ||
y: self.start_y, | ||
hitbox: hitbox, | ||
..EntityState::default() | ||
} | ||
} | ||
fn update(&mut self, | ||
game_state: &mut GameState, | ||
state: &mut EntityState) | ||
-> Vec<EntityEvent<GraphicsEnum>> { | ||
|
||
|
||
state.x -= 0.3f32 * game_state.delta_time; | ||
|
||
if state.x > game_state.screen_width * ONETHIRD && state.x < game_state.screen_width * TWOTHIRD { | ||
state.y += self.diagonal_direction * 0.1f32 * game_state.delta_time; | ||
} | ||
|
||
let mut result = Vec::new(); | ||
|
||
self.bullet_recharge_counter += game_state.delta_time; | ||
if self.bullet_recharge_counter > self.bullet_target_time { | ||
let bullet = Bullet::new(state.x, state.y, false); | ||
self.bullet_recharge_counter -= self.bullet_target_time; | ||
result.push(EntityEvent::SpawnEntity(Box::new(bullet))); | ||
} | ||
result | ||
} | ||
fn draw(&self, state: &EntityState, graphics: &mut EngineGraphics<GraphicsEnum>) -> Result<()> { | ||
graphics.draw(GraphicsEnum::Player, state.x, state.y, PI / 2f32 * 3f32, 1f32) | ||
} | ||
fn collided(&mut self, | ||
self_state: &mut EntityState, | ||
_: &Box<EntityTrait<GraphicsEnum>>, | ||
_: &mut EntityState) | ||
-> Vec<EntityEvent<GraphicsEnum>> { | ||
if self.health <= 1f32 { | ||
self_state.active = false; | ||
} else { | ||
self.health -= 1f32; | ||
} | ||
|
||
Vec::new() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub struct Enemy2 { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub struct Enemy3 { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod enemy_1; | ||
mod enemy_2; | ||
mod enemy_3; | ||
|
||
pub use self::enemy_1::Enemy1; | ||
pub use self::enemy_2::Enemy2; | ||
pub use self::enemy_3::Enemy3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use rand::{StdRng, SeedableRng, Rng}; | ||
use super::{Enemy1, Enemy2, Enemy3}; | ||
use GraphicsEnum; | ||
use engine::*; | ||
|
||
pub struct EnemySpawner { | ||
pub time_counter: f32, | ||
pub target_time_counter: f32, | ||
pub enemy_amount_to_spawn: u32, | ||
pub rng: StdRng, | ||
} | ||
|
||
impl EnemySpawner { | ||
pub fn new() -> EnemySpawner { | ||
let mut spawner = EnemySpawner { | ||
time_counter: 0f32, | ||
target_time_counter: 3000f32, | ||
enemy_amount_to_spawn: 3, | ||
rng: StdRng::from_seed(&[0usize]), | ||
}; | ||
spawner | ||
} | ||
|
||
fn generate_time_target(&mut self) { | ||
let factor = 5000f32 - ((self.enemy_amount_to_spawn - 3) * 100) as f32; | ||
self.target_time_counter = factor + self.rng.next_f32() * factor; | ||
} | ||
} | ||
|
||
impl EntityTrait<GraphicsEnum> for EnemySpawner { | ||
fn identifying_string(&self) -> String { | ||
"Enemy spawner".to_owned() | ||
} | ||
fn update(&mut self, | ||
game_state: &mut GameState, | ||
_: &mut EntityState) | ||
-> Vec<EntityEvent<GraphicsEnum>> { | ||
self.time_counter += game_state.delta_time; | ||
let mut result = Vec::new(); | ||
while self.time_counter > self.target_time_counter { | ||
self.time_counter -= self.target_time_counter; | ||
let height = (game_state.screen_height) * self.rng.next_f32(); | ||
let mut x = game_state.screen_width; | ||
let enemy_type = self.rng.next_u32() % 3 + 1; | ||
println!("Spawning {} enemies at y {}!", self.enemy_amount_to_spawn, height);; | ||
for i in 0..self.enemy_amount_to_spawn { | ||
//match enemy_type { | ||
// | ||
//} | ||
let enemy = Enemy1::new(x, height, self.enemy_amount_to_spawn as f32); | ||
result.push(EntityEvent::SpawnEntity(Box::new(enemy))); | ||
x += 50f32; | ||
} | ||
self.enemy_amount_to_spawn += 1; | ||
self.generate_time_target(); | ||
} | ||
result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
pub mod bullet; | ||
pub mod bullet_spawner; | ||
pub mod player; | ||
pub mod enemy_spawner; | ||
pub mod you_lost; | ||
pub mod enemies; | ||
pub mod bullet; | ||
pub mod player; | ||
|
||
pub use self::enemies::{Enemy1, Enemy2, Enemy3}; | ||
pub use self::bullet_spawner::BulletSpawner; | ||
pub use self::enemy_spawner::EnemySpawner; | ||
pub use self::you_lost::YouLost; | ||
pub use self::bullet::Bullet; | ||
pub use self::player::Player; |
Oops, something went wrong.