Kevin Makes Games
Kevin Makes Games
  • Видео 13
  • Просмотров 27 030
Object Oriented Programming in PICO-8
For developers familiar with object oriented programming who like to create games in PICO-8, this video demonstrates a couple techniques that will help you write object oriented code in LUA.
The Github repo linked below includes an additional cartridge that continues to expand on the topics in the video!
Resources
- Github Repo - github.com/kevinthompson/object-oriented-pico-8
- LUA Metatables - www.lua.org/pil/13.html
- "Using _𝘦𝘯𝘷 in PICO-8" - www.lexaloffle.com/bbs/?tid=49047
Chapters
00:00 Introduction
01:54 Metatables
03:54 Constructor
05:45 Inheritance
08:10 Constructor Overriding
09:09 Refactoring
10:15 Environments
11:41 Saving Tokens
12:52 Global References
14:28 Global Assignment
15:26 Review
16:...
Просмотров: 7 633

Видео

PICO 8 Tips | Using External Tools
Просмотров 15 тыс.3 года назад
Learn how to write code, edit images, and view debug logs using tools outside of the PICO-8 editor! PICO-8: www.lexaloffle.com/pico-8.php Music: Evan King - Groove - Weekly Loops Season 2 ruclips.net/channel/UCT1ZkP03V18LmOj8zbyP-Dw? contextsensitive.bandcamp.com/

Комментарии

  • @trouaconti7812
    @trouaconti7812 2 дня назад

    Thank you a ton! This is very useful

  • @otomichal86
    @otomichal86 14 дней назад

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

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

    when working with external lua files, how do you then "compile" it all together to upload to the pico 8 bbs?

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

      If you have your cart loaded in PICO-8, you can run `save name.p8.png` and it will inline all of the code.

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

    Man your channel rocks

  • @StephaneSavona
    @StephaneSavona 2 месяца назад

    Hi ! thx for your videos :) I've a question : is it a good idea (and possible) to declare globally _ENV=_env and use _ENV directly ? This could avoid having to do ctrl+p several times? And is it possible to use _env without creating a class? Thanks! I didn't know _env thank you :)

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

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

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

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

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

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

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

    With a straight forward OO approach, this would work great as an introductory tutorial to pico8. Thanks for sharing these!

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

    More Godot streams gets a 👍from me - but love the P8 content as well. Thanks for streaming these.

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

    keep it up!

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

    uh may sin!!!

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

      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 :)

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

    Found this randomly on pico8, glad youtube suggested the video

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

    Thank you for the overview of coroutines, they seem awesome!

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

    Love this look into some more advanced projects :) You mentioned looking at TypeScript based engines. Ive heard of Kaboom (currently in the middle of an implosion, it looks like), Phaser, and Excalibur. I was curious as to which ones you were looking at :) As a front-end dev, I would love to use js / ts to make games, but none of the engines have really clicked with me so far. Hope you keep up the streams! Thanks! Mart

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

      I’m in the same position with JS/TS frameworks in that nothing has clicked yet. Excalibur was the latest one I looked into. If I find the perfect framework I’ll definitely share it!

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

    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!

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

    Great video quality! Is that DSLR camera?

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

      I use an Elgato Facecam and a Logitech Litra Glow. They give me a little more control over my setup without breaking the bank or taking up too much space on my desk: - www.elgato.com/us/en/p/facecam - www.logitech.com/en-us/products/lighting/litra-glow.946-000001.html

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

      @@kevinmakesgames Thanks!

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

    Funny, I finished my nvim setup the other day and I found myself thinking: "I wonder what other things I can do with Lua". I wouldn't have imagined "games" was one of the answers. I'm a web developer but I love games and dream of making one myself one day. Pixel art is pretty much all I can aspire to make since I suck at art. I'll keep an eye out for this stream in the future... aaaand subscribed!

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

    Completely unrelated question. What's the name of that Kanban board plugin? Assuming this is a VSCode plugin

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

      It's an app that I use to take notes called Obsidian. obsidian.md It has a number of plugins to add other functionality. What you saw there is the kanban plugin. I also have a drawing plugin for the same app that's nice for sketching out ideas. It lets me keep my notes, drawings and tasks all in one place for game development.

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

      @@kevinmakesgames I spent the last 15 min looking for it and realized that it was indeed my favorite note tool, obsidian. I was on my way here to say "nvm" but you beat me to it. Cool game btw!

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

    The game feels so cute. Love watching a master perform a craft.

  • @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 x<other.x+other.w and x+w>other.x and y<other.y+other.h and h+y>other.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 месяца назад

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

      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!

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

    Cool stream. Game is looking sick!

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

    oh dang wish i caught this live - are you planning on streaming more?

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

      I’d like to figure out a regular schedule. I might be able to stream Wednesday evenings starting this week.

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

      @@kevinmakesgames okay awesome! hope i can catch it! btw thanks for the OOP tutorial and that heartseeker game! i've been learning a lot from it!

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

    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🌱

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

    hai! I make sounds effects and other audio for video games! I'd be willing to do some for free, reply and lmk!

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

    Are you aware of any third-party IDE for pico-8? Do you think there is room for such a thing? (mostly what you're showing here, but packed with dedicated features such as built-in map/sprite editor, using the same retro style as the base pico8 editor)

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

      In a hobbyist community like this there's always space to play around. I don't know how many people would use it, but it could be an interesting project to work on.

  • @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.

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

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

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

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

    What we can stop/step/resume in pico8 ?! Thanks a lots for this tip!

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

      PICO-8 has stop() and resume() functions but in terms of debugging I don't think there's a way to step through logic without building your own logic for stopping after each step.

  • @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.

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

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

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

    This was exactly what I needed, thanks for the video!

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

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

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

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

      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.

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

    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!

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

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

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

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

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

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

      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.

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

    What a great video, thanks!

  • @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.

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

    I'm surprised that circfill works with _ENV when you haven't set class.metatable.

  • @artcadedev
    @artcadedev 10 месяцев назад

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

  • @TheGacko
    @TheGacko 10 месяцев назад

    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.

  • @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.

  • @chiichan5652
    @chiichan5652 10 месяцев назад

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

  • @hickboxgames
    @hickboxgames 10 месяцев назад

    Nice! thanks for this, its very helpful!

  • @jaular14
    @jaular14 10 месяцев назад

    Great video, thank you!

  • @TheTaxicomics
    @TheTaxicomics 10 месяцев назад

    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.

  • @NathanSimmonds
    @NathanSimmonds 10 месяцев назад

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

  • @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?