[-] bi_tux 0 points 2 days ago

if I wasn't a gigahon I'd get gendered female + I just can't love myself because I look like Neil from fonv

[-] bi_tux 4 points 3 days ago

the creepy gigahon (I'm actually a creepy gigahon)

6
submitted 2 weeks ago* (last edited 2 weeks ago) by bi_tux to c/[email protected]

So I want to update the sprite so my character looks in a different direction each time the player presses left/right, how could I do this? I can't do it in the setup fn, since it's a startup system, appreciate any help

EDIT: changed formating

here is my code:

use bevy::prelude::*;

`fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blurry sprites
        .add_systems(Startup, setup)
        .add_systems(Update, animate_sprite)
        .add_systems(Update, player_movement_system)
        .run();
}

const BOUNDS: Vec2 = Vec2::new(1200.0, 640.0);
static mut FLIP_BOOLEAN: bool = false;

fn set_flip_boolean(boolean: bool) {
    unsafe {
        FLIP_BOOLEAN = boolean;
    }
}

fn get_flip_boolean() -> bool{
    unsafe {
        FLIP_BOOLEAN
    }
}

#[derive(Component)]
struct Player {
    movement_speed: f32,
}

#[derive(Component)]
struct AnimationIndices {
    first: usize,
    last: usize,
}

#[derive(Component, Deref, DerefMut)]
struct AnimationTimer(Timer);

fn animate_sprite(
    time: Res<Time>,
    mut query: Query<(&AnimationIndices, &mut AnimationTimer, &mut TextureAtlas)>,
) {
    for (indices, mut timer, mut atlas) in &mut query {
        timer.tick(time.delta());
        if timer.just_finished() {
            atlas.index = if atlas.index == indices.last {
                indices.first
            } else {
                atlas.index + 1
            };
        }
    }
}


fn setup(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    mut texture_atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
) {
    let texture = asset_server.load("sprites/Idle01.png");
    let layout = TextureAtlasLayout::from_grid(Vec2::new(64.0, 40.0), 5, 1, None, None);
    let texture_atlas_layout = texture_atlas_layouts.add(layout);
    let animation_indices = AnimationIndices { first: 0, last: 4 };
    let boolean = get_flip_boolean();
    commands.spawn(Camera2dBundle::default());
    commands.spawn((
        SpriteSheetBundle {
            texture,
            atlas: TextureAtlas {
                layout: texture_atlas_layout,
                index: animation_indices.first,
            },
            
            ..default()
        },
        Player {
            movement_speed: 500.0,
        },
        animation_indices,
        AnimationTimer(Timer::from_seconds(0.1, TimerMode::Repeating)),
    ));
}

fn player_movement_system(
    time: Res<Time>,
    keyboard_input: Res<ButtonInput<KeyCode>>,
    mut query: Query<(&Player, &mut Transform)>,
) {
    let (guy, mut transform) = query.single_mut();

    let mut movement_factor = 0.0;

    let mut movement_direction = Vec3::X;

    if keyboard_input.pressed(KeyCode::ArrowLeft) {
        movement_factor -= 1.0;
        movement_direction = Vec3::X;
        set_flip_boolean(true);
    }

    if keyboard_input.pressed(KeyCode::ArrowRight) {
        movement_factor += 1.0;
        movement_direction = Vec3::X;
        set_flip_boolean(false);
    }

    if keyboard_input.pressed(KeyCode::ArrowUp) {
        movement_factor += 1.0;
        movement_direction = Vec3::Y;
    }

    if keyboard_input.pressed(KeyCode::ArrowDown) {
        movement_factor -= 1.0;
        movement_direction = Vec3::Y;
    }


    let movement_distance = movement_factor * guy.movement_speed * time.delta_seconds();
    let translation_delta = movement_direction * movement_distance;
    transform.translation += translation_delta;

    let extents = Vec3::from((BOUNDS / 2.0, 0.0));
    transform.translation = transform.translation.min(extents).max(-extents);
}
7
submitted 1 month ago by bi_tux to c/guns

I hope this isn't out of context, also I don't want to "own the libs" or something here, I'm actually interested.

6
submitted 1 month ago* (last edited 1 month ago) by bi_tux to c/health

I don't know where else to post this, so here you go:

  • How reliable is the yazio kcal counter
  • Does it use anything
  • Are there FOSS alternatives

the reason I'm asking is because I weighted everything I ate and put it into the app, according to the app I should have eaten 1600kcal, but I feel lile I ate 3000kcal

EDIT: I mean the kcal I ate all day, I didn't eat that much at once obviosly

would appreciate help and advise

106
submitted 1 month ago* (last edited 1 month ago) by bi_tux to c/[email protected]

tbh I did a horrible paint job, but she still liked it

EDIT: the parts are 3d printed (not my model tho)

[-] bi_tux 41 points 1 month ago

I maybe don't get the meme, but why would western communists like modern russia? the most supporters of russia I know irl are far right

[-] bi_tux 43 points 1 month ago

for a moment there I didn't get it, since it can't possibly have 65° on a land that grows grass yet, then I realised you have never heared of Celcius

[-] bi_tux 50 points 2 months ago

accorns are brown... I'm sure it had a gun

123
submitted 2 months ago by bi_tux to c/lemmyshitpost
55
submitted 3 months ago by bi_tux to c/[email protected]
328
submitted 3 months ago by bi_tux to c/[email protected]
[-] bi_tux 58 points 3 months ago

the concept of science fiction is way to librul, since it suggests that science is real

99
submitted 4 months ago by bi_tux to c/[email protected]
85
submitted 4 months ago by bi_tux to c/[email protected]
47
submitted 4 months ago by bi_tux to c/[email protected]
218
riker be like (lemmy.world)
submitted 4 months ago by bi_tux to c/[email protected]
45
submitted 4 months ago by bi_tux to c/[email protected]
[-] bi_tux 46 points 5 months ago

If it was released today we'd have another rage from the "fucking pronouns" guy

[-] bi_tux 41 points 5 months ago

Why is this petrol station so big? I could park 2 tanks between the petrol pumps.

Why would you eat pizza for breakfast?

Why would you drink so much cola (this looks like 1l-1.5l to me)?

How is this so cheap? They charge 4€ at my local petrol station for 0.5l of pepsi alone.

What kind of pizza is this?

Is midwest some kind of common marketing?

[-] bi_tux 47 points 6 months ago
[-] bi_tux 55 points 7 months ago

Young men are always more likely to fall for investment scams

[-] bi_tux 42 points 7 months ago

Laser cooling exists, but I don't suppose you can afford one or want your beer on 2°K

[-] bi_tux 41 points 9 months ago* (last edited 9 months ago)

Media piracy.

If I wanted to watch a show, I'd have to pay 80€/month, because every streaming site only has one or two seasons.

I'm just done with corporate greed, fuck big companies, piracy is a service problem.

view more: next ›

bi_tux

joined 9 months ago