Kevin Makes Games
Kevin Makes Games
  • Видео 13
  • Просмотров 29 408
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:...
Просмотров: 8 786

Видео

PICO 8 Tips | Using External Tools
Просмотров 16 тыс.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/

Комментарии

  • @hannesvz82
    @hannesvz82 18 дней назад

    Excellent video! Your explanation style is perfect.

  • @unnatural.mp3
    @unnatural.mp3 29 дней назад

    this was sooo useful!

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

    Amazing, now that I watch 50% of your youtube videos, I'm going to reach 100% and then starting watch your past livestreams.

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

    Fantastic video. Thank you Kevin and thank you YT algorhythm!

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

    Great video!

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

    Thank you a ton! This is very useful

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

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

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

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

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

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

    Man your channel rocks

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

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

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

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

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

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

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

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

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

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

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

    keep it up!

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

    uh may sin!!!

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

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

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

    Found this randomly on pico8, glad youtube suggested the video

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

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

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

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

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

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

    Great video quality! Is that DSLR camera?

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

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

      @@kevinmakesgames Thanks!

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

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

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

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

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

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

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

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

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

      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!

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

    Cool stream. Game is looking sick!

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

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

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

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

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

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

  • @ПетрМосевич
    @ПетрМосевич 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🌱

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      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.

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

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

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

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

      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.

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

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

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

    What a great video, thanks!

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

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

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

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

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

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

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

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

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