mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-09-28 21:19:24 +00:00
add flipped face support and make the lighting switch like
This commit is contained in:
parent
e2cfc898ac
commit
4b21d9d786
|
@ -465,9 +465,16 @@ impl GameScene {
|
||||||
};
|
};
|
||||||
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, tex_name)?;
|
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, tex_name)?;
|
||||||
|
|
||||||
batch.add_rect(left_pos + 14.0, top_pos + 8.0, &Rect::<usize>::new_size(
|
// switch version uses +100 face offset to display a flipped version
|
||||||
(state.textscript_vm.face as usize % 6) * 48,
|
let flip = state.textscript_vm.face > 100;
|
||||||
(state.textscript_vm.face as usize / 6) * 48,
|
let face_num = state.textscript_vm.face % 100;
|
||||||
|
let (scale_x, scale_y) = batch.scale();
|
||||||
|
|
||||||
|
batch.add_rect_scaled(left_pos + 14.0 + if flip { 48.0 } else { 0.0 }, top_pos + 8.0,
|
||||||
|
scale_x * if flip { -1.0 } else { 1.0 }, scale_y,
|
||||||
|
&Rect::<usize>::new_size(
|
||||||
|
(face_num as usize % 6) * 48,
|
||||||
|
(face_num as usize / 6) * 48,
|
||||||
48, 48,
|
48, 48,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -527,6 +534,10 @@ impl GameScene {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_light_map(&self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
fn draw_light_map(&self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||||
|
if self.stage.data.background_type == BackgroundType::Black {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
graphics::set_canvas(ctx, Some(&state.lightmap_canvas));
|
graphics::set_canvas(ctx, Some(&state.lightmap_canvas));
|
||||||
graphics::set_blend_mode(ctx, BlendMode::Add)?;
|
graphics::set_blend_mode(ctx, BlendMode::Add)?;
|
||||||
|
|
||||||
|
@ -970,6 +981,10 @@ impl Scene for GameScene {
|
||||||
fn draw(&self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
fn draw(&self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||||
self.draw_background(state, ctx)?;
|
self.draw_background(state, ctx)?;
|
||||||
self.draw_tiles(state, ctx, TileLayer::Background)?;
|
self.draw_tiles(state, ctx, TileLayer::Background)?;
|
||||||
|
if state.enhanced_graphics {
|
||||||
|
self.draw_light_map(state, ctx)?;
|
||||||
|
}
|
||||||
|
|
||||||
for npc_id in self.npc_map.npc_ids.iter() {
|
for npc_id in self.npc_map.npc_ids.iter() {
|
||||||
if let Some(npc_cell) = self.npc_map.npcs.get(npc_id) {
|
if let Some(npc_cell) = self.npc_map.npcs.get(npc_id) {
|
||||||
npc_cell.borrow().draw(state, ctx, &self.frame)?;
|
npc_cell.borrow().draw(state, ctx, &self.frame)?;
|
||||||
|
@ -980,9 +995,6 @@ impl Scene for GameScene {
|
||||||
self.draw_tiles(state, ctx, TileLayer::Foreground)?;
|
self.draw_tiles(state, ctx, TileLayer::Foreground)?;
|
||||||
self.draw_tiles(state, ctx, TileLayer::Snack)?;
|
self.draw_tiles(state, ctx, TileLayer::Snack)?;
|
||||||
self.draw_carets(state, ctx)?;
|
self.draw_carets(state, ctx)?;
|
||||||
if state.enhanced_graphics {
|
|
||||||
self.draw_light_map(state, ctx)?;
|
|
||||||
}
|
|
||||||
self.draw_black_bars(state, ctx)?;
|
self.draw_black_bars(state, ctx)?;
|
||||||
|
|
||||||
if state.control_flags.control_enabled() {
|
if state.control_flags.control_enabled() {
|
||||||
|
|
|
@ -1212,7 +1212,9 @@ impl TextScript {
|
||||||
b'#' => {
|
b'#' => {
|
||||||
iter.next();
|
iter.next();
|
||||||
let event_num = TextScript::read_number(&mut iter)? as u16;
|
let event_num = TextScript::read_number(&mut iter)? as u16;
|
||||||
|
if iter.peek().is_some() {
|
||||||
TextScript::skip_until(b'\n', &mut iter)?;
|
TextScript::skip_until(b'\n', &mut iter)?;
|
||||||
|
}
|
||||||
last_event = event_num;
|
last_event = event_num;
|
||||||
|
|
||||||
if event_map.contains_key(&event_num) {
|
if event_map.contains_key(&event_num) {
|
||||||
|
|
|
@ -46,6 +46,11 @@ impl SizedBatch {
|
||||||
(self.real_width, self.real_height)
|
(self.real_width, self.real_height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn scale(&self) -> (f32, f32) {
|
||||||
|
(self.scale_x, self.scale_y)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn to_rect(&self) -> common::Rect<usize> {
|
pub fn to_rect(&self) -> common::Rect<usize> {
|
||||||
common::Rect::<usize>::new(0, 0, self.width, self.height)
|
common::Rect::<usize>::new(0, 0, self.width, self.height)
|
||||||
|
|
Loading…
Reference in a new issue