Object Oriented Programming in PICO-8

Поделиться
HTML-код
  • Опубликовано: 16 дек 2024

Комментарии • 55

  • @danmightbetheman
    @danmightbetheman 10 месяцев назад +9

    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!

  • @hannesvz82
    @hannesvz82 19 дней назад +1

    Excellent video! Your explanation style is perfect.

  • @BrianGreigRWD
    @BrianGreigRWD Год назад +10

    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.

  • @edwardmullins2176
    @edwardmullins2176 9 месяцев назад +2

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

  • @MrGiaBoz
    @MrGiaBoz 6 месяцев назад +2

    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!

  • @11sveden12
    @11sveden12 Год назад +1

    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.

  • @peechiz
    @peechiz Год назад +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.

  • @otomichal86
    @otomichal86 3 месяца назад

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

  • @chiichan5652
    @chiichan5652 Год назад +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 🎉🎉.

  • @TheGacko
    @TheGacko Год назад

    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.

  • @DrNabeel20
    @DrNabeel20 5 месяцев назад

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

  • @artcadedev
    @artcadedev Год назад

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

  • @madclouds
    @madclouds Год назад

    What a great introduction to OOP! Thanks for sharing

  • @loldoctor
    @loldoctor 8 месяцев назад

    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.

  • @juleslib
    @juleslib 10 месяцев назад +2

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

    • @kevinmakesgames
      @kevinmakesgames  10 месяцев назад +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 8 месяцев назад

      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 RUclips.

  • @VoidFriend
    @VoidFriend 5 месяцев назад

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

  • @NathanSimmonds
    @NathanSimmonds Год назад +1

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

  • @carl4352
    @carl4352 Месяц назад

    Great video!

  • @joaquimg5361
    @joaquimg5361 4 месяца назад

    Man your channel rocks

  • @TheTaxicomics
    @TheTaxicomics Год назад +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.

  • @beriadan77
    @beriadan77 8 месяцев назад +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  7 месяцев назад +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 7 месяцев назад

      @@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!!

  • @jaular14
    @jaular14 Год назад

    Great video, thank you!

  • @jimmac
    @jimmac 8 месяцев назад

    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.

  • @hickboxgames
    @hickboxgames Год назад

    Nice! thanks for this, its very helpful!

  • @ПетрМосевич
    @ПетрМосевич 7 месяцев назад

    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🌱

  • @PICO-ARCADE
    @PICO-ARCADE Год назад

    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  Год назад +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 Год назад

      @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 Год назад

      @@kevinmakesgames Yes to all of this. :)

  • @keithrobinson2016
    @keithrobinson2016 10 месяцев назад +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  10 месяцев назад +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.

  • @YoYoYo
    @YoYoYo Год назад

    Really helpful!

  • @voidquaternion
    @voidquaternion 9 месяцев назад

    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  9 месяцев назад +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 9 месяцев назад

      @@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 10 месяцев назад

    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  10 месяцев назад +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 10 месяцев назад

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

  • @anon_y_mousse
    @anon_y_mousse 5 месяцев назад

    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 4 месяца назад

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

  • @terr0rbyte997
    @terr0rbyte997 7 месяцев назад

    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  7 месяцев назад +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 7 месяцев назад

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

    • @kevinmakesgames
      @kevinmakesgames  7 месяцев назад +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 7 месяцев назад

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

  • @BatteryProductions
    @BatteryProductions 6 месяцев назад

    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  6 месяцев назад +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 6 месяцев назад

      @@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 Год назад

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

    • @kevinmakesgames
      @kevinmakesgames  Год назад

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