finally works fml
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 214 B After Width: | Height: | Size: 200 B |
Binary file not shown.
|
Before Width: | Height: | Size: 338 B After Width: | Height: | Size: 324 B |
+6
-6
@@ -46,13 +46,13 @@ int start_game() {
|
||||
|
||||
read_debug_input();
|
||||
if (IsKeyPressed(KEY_E)) {
|
||||
if (!player.current_item) {
|
||||
equip_item(&player, create_item_sword());
|
||||
}
|
||||
else {
|
||||
unequip_item(&player);
|
||||
}
|
||||
unequip_item(&player);
|
||||
equip_item(&player, create_item_sword());
|
||||
}
|
||||
if (IsKeyPressed(KEY_R)) {
|
||||
unequip_item(&player);
|
||||
equip_item(&player, create_item_lance());
|
||||
}
|
||||
|
||||
|
||||
// RENDER
|
||||
|
||||
+5
-5
@@ -11,18 +11,18 @@ item_t* create_item_lance() {
|
||||
|
||||
itemdata_meele_t* data = get_meele_data(item_p->item_data);
|
||||
data->animation[0] = (item_transl_t) {(Vector2) {0,0}, (float) 0.0f};
|
||||
data->animation[1] = (item_transl_t) {(Vector2) {0,-2}, (float) -40.0f};
|
||||
data->animation[2] = (item_transl_t) {(Vector2) {0,-1}, (float) 30.0f};
|
||||
data->animation[3] = (item_transl_t) {(Vector2) {0,0}, (float) 20.0f};
|
||||
data->animation[1] = (item_transl_t) {(Vector2) {5,0}, (float) 0.0f};
|
||||
data->animation[2] = (item_transl_t) {(Vector2) {3,0}, (float) 0.0f};
|
||||
data->animation[3] = (item_transl_t) {(Vector2) {2,0}, (float) 0.0f};
|
||||
data->animation[4] = (item_transl_t) {(Vector2) {0,0}, (float) 0.0f};
|
||||
|
||||
data->used_frames = 5; // not as index
|
||||
data->animation_length_ms = 1000;
|
||||
data->animation_length_ms = 700;
|
||||
|
||||
item_p->cooldown_ms = 700;
|
||||
|
||||
item_p->sprite = LoadTexture("assets/sprites/items/lance.png");
|
||||
item_p->render_offset = (Vector2) { -8, -5 };
|
||||
item_p->render_offset = (Vector2) { -3, -5 };
|
||||
|
||||
item_p->type = MEELE_WEAPON;
|
||||
item_p->item_action = &meele_item_attack;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
item_t* create_item_sword() {
|
||||
item_t* item_p = create_meele_item_base();
|
||||
item_p->rot_origin_offs = (Vector2) { 0, 0 };
|
||||
item_p->rot_origin_offs = (Vector2) { 0, 16 };
|
||||
|
||||
itemdata_meele_t* data = get_meele_data(item_p->item_data);
|
||||
data->animation[0] = (item_transl_t) {(Vector2) {0,0}, (float) 0.0f};
|
||||
|
||||
+8
-9
@@ -142,19 +142,18 @@ void render_player_item(player_t* player) {
|
||||
Vector2 flipped_rend_offs = Vector2Add(item->render_offset, anim_offset.position);
|
||||
flipped_rend_offs.x *= what_the_flip;
|
||||
|
||||
Vector2 flipped_anim_offs = anim_offset.position;
|
||||
flipped_anim_offs.x *= what_the_flip;
|
||||
|
||||
float origin_offs_x = item->rot_origin_offs.x + (item_size.x * player->entity.anim.flipped);
|
||||
|
||||
Rectangle src = { 0, 0, item_size.x * what_the_flip, item_size.y };
|
||||
Rectangle dest = {
|
||||
player->entity.position.x + flip_dep_ply_width + flipped_rend_offs.x - flipped_item_size.x, // + (item->rot_origin_offs.x * what_the_flip) + flip_dep_ply_width,
|
||||
player->entity.position.y + flipped_rend_offs.y, // + item->rot_origin_offs.y,
|
||||
player->entity.position.x + flip_dep_ply_width + flipped_rend_offs.x - flipped_item_size.x + flipped_anim_offs.x + origin_offs_x,
|
||||
player->entity.position.y + flipped_rend_offs.y + item->rot_origin_offs.y,
|
||||
item_size.x, item_size.y
|
||||
};
|
||||
|
||||
printf("DEST: %f, %f\n", dest.x, dest.y);
|
||||
printf("FDPW: %d\n", flip_dep_ply_width);
|
||||
printf("FIS.x: %f\n", flipped_item_size.x);
|
||||
printf("PLAYER: %f, %f\n", player->entity.position.x, player->entity.position.y);
|
||||
player->entity.position = Vector2Zero();
|
||||
|
||||
float player_ypos = get_entity_bottom(&player->entity);
|
||||
push_to_render_buffer((renderdata_t) {
|
||||
.name = "sword",
|
||||
@@ -163,7 +162,7 @@ void render_player_item(player_t* player) {
|
||||
.texture = item->sprite,
|
||||
.src = src,
|
||||
.dest = dest,
|
||||
.origin = Vector2Zero(),//(Vector2){item->rot_origin_offs.x - flip_dep_ply_width, item->rot_origin_offs.y},
|
||||
.origin = (Vector2) {origin_offs_x, item->rot_origin_offs.y},
|
||||
.rotation = anim_offset.rotation * what_the_flip,
|
||||
.tint = WHITE,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user