Object Oriented Programming in PICO-8

Поділитися
Вставка
  • Опубліковано 23 вер 2024

КОМЕНТАРІ • 53

  • @danmightbetheman
    @danmightbetheman 7 місяців тому +6

    I'm not going to act like I totally understand how metatables work or anything like that, but I can tell that inheritance and the ability to cut down on all the "self." calls is incredibly powerful! Thanks for this tutorial!

  • @BrianGreigRWD
    @BrianGreigRWD 9 місяців тому +9

    This video is really well done. So much great info. Looking forward to more advanced topics. So many of the pico 8 videos on YT are just the basics on tables, control structures, variable assignment. This is the type of resource I’ve been looking for.

  • @otomichal86
    @otomichal86 7 днів тому

    That's what I was waiting for. Thank you Kevin! Cheers.👌

  • @peechiz
    @peechiz 10 місяців тому +5

    I definitely had trouble figuring out the colon syntax for calling methods that need a reference to `self` (which I _think_ I get now), so that would be cool to cover. I appreciate the explanation of _ENV, since that was something I definitely didn't know about and a lot of the tutorials shy away from OOP in order to make them more beginner friendly. I love that this can save tokens AND make the code more readable.

  • @MrGiaBoz
    @MrGiaBoz 4 місяці тому +1

    Instant subbed. Very well put together video.
    As a web developer, mostly JS and TS, I don't know LUA at all, this helps a lot 😊
    Thank you!

  • @edwardmullins2176
    @edwardmullins2176 6 місяців тому +1

    This information about _env and variable scope is blowing my mind!

  • @chiichan5652
    @chiichan5652 10 місяців тому +1

    Glad that you're back! Subcribed from the vscode pico8 dev environment setup. Hope that you will continue making tutorials. Have a nice day 🎉🎉.

  • @DrNabeel20
    @DrNabeel20 2 місяці тому

    Wow! That is super super useful. Such an underrated channel and tutorial.
    Thank you very much!

  • @11sveden12
    @11sveden12 9 місяців тому

    This is such an outstanding resource. Thank you for making this and please continue making videos on these advanced topics. It will be instrumental in helping developers break through to being able to create scalable projects.

  • @loldoctor
    @loldoctor 5 місяців тому

    Amazing video. Also, incredible amount of finesse on the mouse movements. I hope you're able to make more guides like this, particularly for Picotron (which I feel will make even more people interested to this hobby). As a hobbyist myself, I've never looked too deep into Lua, so this was fairly mind-blowing for me.

  • @TheGacko
    @TheGacko 9 місяців тому

    Nice video - well explained. I've been doing functional method with Pico8 as a hobbyist (not a programmer) and I was interested in how the OO approach worked. I can see reading other peoples carts, and I had inklings, but your video really helped explain it well with a simple understandable example.

  • @artcadedev
    @artcadedev 9 місяців тому

    It took around 8 seconds for me to subscribe after clicking on the video, keep up the good work bud

  • @TheTaxicomics
    @TheTaxicomics 10 місяців тому +1

    Great video! I love getting to know another approach. Coming from python I should, in theory, also prefer this approach, but somehow i just prefer writing some absolutely unreadable messy code.

  • @madclouds
    @madclouds 10 місяців тому

    What a great introduction to OOP! Thanks for sharing

  • @NathanSimmonds
    @NathanSimmonds 10 місяців тому +1

    What a great tutorial, thanks. I've been wondering how to deal with all the token-eating table.* references in my game.

  • @juleslib
    @juleslib 8 місяців тому +2

    Thank you Kevin ❤ I can wait 2 more years for a new vid, your content is outstanding

    • @kevinmakesgames
      @kevinmakesgames  7 місяців тому +2

      I'd love to create content more often, and I've got a few more ideas brewing. Life and work tend to be pretty busy most weeks but I mostly get the itch to make a video when I see a topic that nobody else is covering. Anything specific you're interested in knowing more about?

    • @PanosGeorgiadis
      @PanosGeorgiadis 6 місяців тому

      Show how Link can jump in top down Zelda, like Link to the past or Awakening. Pretty neat mechanic with shadow and illusion, nowhere to be found in UA-cam.

  • @VoidFriend
    @VoidFriend 3 місяці тому

    🤯🤯🤯 Mind blowing information, thanks for the vid 🙏

  • @keithrobinson2016
    @keithrobinson2016 8 місяців тому +1

    Nice tutorial.
    I have a query: why does circfill() not need to be accessed as global.circfill(), as I imagine its in the global scope the same as score?

    • @kevinmakesgames
      @kevinmakesgames  8 місяців тому +2

      The difference is assignment. With the += operator we end up reading the global value of score, but it's assigned to the current environment instead of the global environment. Because circfill is only being read, we still get the global function that was originally defined.

  • @ПетрМосевич
    @ПетрМосевич 4 місяці тому

    thank you for this video! I've been struggling with metatables for a while and now, thanks to you, i'm finally starting to understand it! One thing i'm still struggling with is collision of objects of the same class(or the same kind). I can't make a lot of them collide without overloading pico 8, but i feel it is possible and metatables must be the key to it. Maybe you could give me a tip on that one. Anyway thank you for a great tutorial🌱

  • @joaquimg5361
    @joaquimg5361 Місяць тому

    Man your channel rocks

  • @PICO-ARCADE
    @PICO-ARCADE 10 місяців тому

    A lot to take in, but I really enjoyed the pace and instructions here. You definitely should be making more videos. For me as a nub things like _env I don't fully understand. So videos on things like that and tables and all the basics to advanced. Not sure if you want to put in time on basics as a lot of resources are already out there but sometimes hearing it from different teachers helps with understanding.

    • @kevinmakesgames
      @kevinmakesgames  10 місяців тому +1

      I really appreciate the encouragement! I actually started planning this video as a series building up to dedicated videos on metatables and environments but second-guessed the value of that more beginner-friendly content. Now that I have the process ironed out I'd love to create more videos. Maybe I'll create a few prequels to this one next!

    • @PICO-ARCADE
      @PICO-ARCADE 10 місяців тому

      @made-by-kevin that would be epic! I love seeing content on pico-8 that teaches. So any info building up to this would be super helpful!

    • @AlexFalkenberg
      @AlexFalkenberg 9 місяців тому

      @@kevinmakesgames Yes to all of this. :)

  • @jimmac
    @jimmac 6 місяців тому

    I kludged together my pico game, but it was super hard to navigate the state machine at the end. This looks like the way to go for a more complex game.

  • @beriadan77
    @beriadan77 5 місяців тому +1

    I'm trying to adapt your strategy to building a game that has a class/entity/actor and then player, enemy, etc. inheriting from class/entity/actor of course... but I'm totally stuck, when should I use the parent class' constructor, when not to, etc. It'd be great to see an OOP implementation on Pico-8 about this!

    • @kevinmakesgames
      @kevinmakesgames  4 місяці тому +1

      Sorry for the late reply on this. It's up to you if/when you should use the parent classes constructor. Most of the time you probably want to execute some functionality _in addition_ to the parent classes constructor, but not necessarily every time.
      It might not be a great example of this but I do have another cart over on Github that wasn't shown in the video: github.com/kevinthompson/object-oriented-pico-8/blob/main/heartseeker.p8

    • @beriadan77
      @beriadan77 4 місяці тому

      @@kevinmakesgames yes! Saw your response to some other person and check it out. It’s be great to see a new video tutorial showcasing how to for instance, modify the actors’ movement based on their type or how to still use the base constructor and add in some extra functionality. I got it to work eventually, but it is still not 100% clear in my head.
      Thanks for your reply! Looking forward to more of your videos!!

  • @hickboxgames
    @hickboxgames 10 місяців тому

    Nice! thanks for this, its very helpful!

  • @jaular14
    @jaular14 10 місяців тому

    Great video, thank you!

  • @YoYoYo
    @YoYoYo 10 місяців тому

    Really helpful!

  • @anon_y_mousse
    @anon_y_mousse 2 місяці тому

    Know of any open source Pico-8 implementations? I'd love to relax the restrictions somewhat because it shouldn't eat two tokens to say object.method and I'd love to play some Pico-8 games without using the browser.

    • @loldoctor
      @loldoctor Місяць тому

      TIC-80 I think is open source now. Picotron recently released, which is sort of what you’re looking for but paid.

  • @voidquaternion
    @voidquaternion 6 місяців тому

    I'm curious is it also possible to override a function and call something like "base.function" from the child one ?
    Or in your starfield example, how will you implemented a new star drawing a square, or an animated sprite ? I start to make some test and struggle to have a function in the parent class call a method redefine in the child class

    • @kevinmakesgames
      @kevinmakesgames  6 місяців тому +1

      Let's say for our far_star we wanted to render the star and then something else around it. far_star might have a draw function that calls star.draw(self) which would essentially call the parent classes draw method, but using the far_star as the current table.
      It's also possible to setup your constructor to have a parent, base, or super reference, but the constructor starts getting a bit more complex and it felt too complicated to share in this video.
      I threw together a quick example but it's untested so I can't guarantee the code is 100% correct: gist.github.com/kevinthompson/7a82446dc54b34d731d641b6190d4f42

    • @voidquaternion
      @voidquaternion 6 місяців тому

      @@kevinmakesgamesThanks, I manage to make it work, replace some . by : and adding some self before base. Trying to reply but apparently it's delete by yt. Gonna made a last try without any url. The gist can be found here malmontagne 75074b44854723d3fe7249f4076d16df.

  • @molochz
    @molochz 7 місяців тому

    How would I set up a player using this method?
    I've seen something similar in the Celeste code but I can't understand it.
    It's similar to this example but I don't know how to call it.
    player =
    {
    init=function(this)
    end,
    update=function(this)
    end,
    draw=function(this)
    end
    }

    • @kevinmakesgames
      @kevinmakesgames  7 місяців тому +1

      In the github repo linked in the description there is a cartridge called `heartseeker.p8` that uses a `person` class as the player. I didn't cover that cartridge in the video but it's an example of a slightly more complex project if you want to use that as a reference. Here's where the person class is defined: github.com/kevinthompson/object-oriented-pico-8/blob/main/heartseeker.p8#L308-L349

    • @molochz
      @molochz 7 місяців тому

      @@kevinmakesgames Oh that's awesome. Thank you.

  • @terr0rbyte997
    @terr0rbyte997 4 місяці тому

    Hey! I'm failing to understand how your collision detection works in the heartseeker demo, right now I've been working on a small pong game to work with your way of doing oop. do you think you could provide some assistance with that? right now it seems to repeatedly call the callback function despite not colliding with anything:
    from entity:
    detect=function(_𝘦𝘯𝘷,other,callback)
    if collide(_𝘦𝘯𝘷, other) then
    callback(_𝘦𝘯𝘷)
    end
    end,

    collide=function(_𝘦𝘯𝘷,other)
    return xother.x and
    yother.y
    end,
    gamescene instantiates p1and p2 as new paddle entities, and gball as a ball entity
    from gamescene's update:
    update=function(_𝘦𝘯𝘷)
    entity:each("update")
    ball:each("detect",p1,function(obj)
    sfx(0)
    end)
    end,
    not much is in the callback function as right now i'm just trying to play the sfx when it is colliding with P1
    I might just be completely misunderstanding how this is supposed to work

    • @kevinmakesgames
      @kevinmakesgames  4 місяці тому +1

      Are you able to post the full cartridge somewhere and send me a link? Nothing is jumping out at me in the code you shared.

    • @terr0rbyte997
      @terr0rbyte997 4 місяці тому

      @@kevinmakesgames ill do that as soon as i can! Thanks!

    • @kevinmakesgames
      @kevinmakesgames  4 місяці тому +2

      This turned out to be a bug in my heartseeker.p8 example cart. I've fixed the bug and updated the code on github: github.com/kevinthompson/object-oriented-pico-8/blob/main/heartseeker.p8
      Thanks for pointing that out @terr0rbyte997!

    • @terr0rbyte997
      @terr0rbyte997 4 місяці тому

      @@kevinmakesgames No problem! thanks for the quick answer and support!

  • @BatteryProductions
    @BatteryProductions 3 місяці тому

    almost overheated my brain but after three times i got it, just one thing.. _env and _ENV, how to write _ENV in pico, if i use shift i get symbols...

    • @kevinmakesgames
      @kevinmakesgames  3 місяці тому +1

      Ah! I may have forgotten to cover that but if you’re working directly in PICO-8 then you have to press CTRL+P to enable puny font to type the equivalent of _ENV, which will look like a smaller font.

    • @BatteryProductions
      @BatteryProductions 3 місяці тому

      @@kevinmakesgames your only two uploads are THEE two most useful pico8 videos ive seen, i wish you had 100 videos xD thanks a lot man :)

  • @bblevins
    @bblevins 10 місяців тому

    Nice vid, but I wish you had one way more basic.

    • @kevinmakesgames
      @kevinmakesgames  10 місяців тому

      Thanks for the feedback. Is there anything specific that would be most helpful?