📍🇲🇽; 20 yo; 🏳‍⚧ (she/her); [es, en, pt, fr, eo]; Developer, FOSS advocate.

Levanta la multicolor. ¡Viva la diversidad!

About me: https://autumn64.xyz/

  • 12 Posts
  • 16 Comments
Joined 8 months ago
cake
Cake day: November 7th, 2023

help-circle



  • C programmer here. I can’t code in Rust and although I do have some interest in learning it, C is still the best one to me. Probably not the best way to do it, but I’d do something like this (based on the code in your ss):

    typedef struct Player{
          float pos_x;
          float pos_y;
          float rotation;
    } Player;
    
    Player player_new(){
          Player player;
          player.pos_x = 0.0;
          player.pos_y = 0.0;
          player.rotation = 0.0;
          return player;
    }
    
    void player_move(Player *player, float x, float y){
          player->pos_x += x;
          player->pos_y += y;
          return;
    }
    
    void player_rotate(Player *player, float by){
          player->rotation += by;
          return;
    }
    
    int main(int argc, char *argv[]){
          Player player1 = player_new();
          player_move(&player1, 10.0, 10.0);
          player_rotate(&player1, 180.0);
    
          return 0;
    }
    
    

    I would probably move the struct Player and the functions player_new, player_move and player_rotate to another file (like player.c or sth), I’d create its respective header file with the definitions of each thing and with that I basically created a simple interface to create and handle players without needing OOP. English is not my native language, so I’m not really sure about what’s the name of the programming paradigm used in C (which definitely is not OOP), but in my native language we call it “programación estructurada”, which in English would be something like “structured programming”.

    Tbh I code in both non-OOP and OOP languages (most of the time C, JS and Python) and to me both paradigms are just fine. You can pretty much do anything in either, but each of them might work better for you on different situations and depending on your needs. I also use Vim btw.























  • 𝓜𝓸𝓷𝓲@lemmy.blahaj.zonetolinuxmemes@lemmy.worldOh no ...
    link
    fedilink
    arrow-up
    14
    arrow-down
    1
    ·
    8 months ago

    I mean, do the people at the fediverse really talk mainly about Linux? I see in both Lemmy and Mastodon more people talking about US politics, LGBTQ+ stuff and furrys (lmao) than anything related to technology in general. I guess the kind of content someone sees would depend a lot on the instance someone creates their account in?