Object Oriented Programming for the Playdate SDK

  Рет қаралды 11,568

SquidGod

SquidGod

Күн бұрын

This video is made for complete beginners to the concept of object oriented programming (OOP). I go over what object oriented programming is, core concepts that make it up, as well as a simple example of coding with object oriented programming - all in this jam packed, 13 minute tutorial for the Playdate SDK using the Lua programming language.
Timestamps:
0:00 - Intro
0:55 - Encapsulation
1:47 - Abstraction
3:25 - Inheritance
4:36 - Polymorphism
5:23 - OOP Concept Recap
6:00 - Code Example Intro
6:22 - Creating Our First Class
10:05 - Adding Shoot and Ability Methods
10:48 - Creating Player Archetypes/Child Objects
12:27 - Checking Class Type
Source Code for OOP Example: github.com/SquidGodDev/Playda...
Support me on Patreon to help me make more of these videos and get access to my Playdate games/source code!: / squidgoddev
Join my Discord (I'm very active!): / discord
Follow me on Twitter (See what I'm working on early): / squidgoddev
I get my music and sfx from Epidemic Sound. Get 1 month free with my link! share.epidemicsound.com/njknzw
#Playdate #PlaydateSDK #PlaydateConsole

Пікірлер: 34
@Jayceh2
@Jayceh2 2 жыл бұрын
Was having trouble in understanding OOP concepts in Java but this video cleared up a lot of the concepts I had trouble in understanding. Thanks a lot!
@SquidGodDev
@SquidGodDev 2 жыл бұрын
Awesome! Glad I could help - even in the context of other languages
@avery_IO
@avery_IO 2 жыл бұрын
loving this. keep going!!!
@SquidGodDev
@SquidGodDev 2 жыл бұрын
Will do - thanks!
@andrewhamel1
@andrewhamel1 2 жыл бұрын
When you showed the isA method I had a small heart attack thinking of what the console is going to do when people are calling it many times a frame.. once you get your console hopefully we can see a top X playdate optimizations video! Awesome stuff thanks again
@SquidGodDev
@SquidGodDev 2 жыл бұрын
Well, my guess is that isA is an inexpensive operation. I imagine it's basically just a string comparison which is only like a couple machine instructions. But yeah I will definitely do some sort of optimizations video once I get my hands on the hardware to see what you can and can't do.
@LazoDev
@LazoDev 2 жыл бұрын
i 👍 these videos eve dough idk what u talking about but keep going
@SquidGodDev
@SquidGodDev 2 жыл бұрын
LOL no worries that's what my friends and family say about my tutorials too. Thanks!
@thetexanshurtme
@thetexanshurtme 2 жыл бұрын
Even more channel growth
@86davy
@86davy 2 жыл бұрын
Hyper light drifter!!!!!!!! That would b epic on play date! Where the crank is used for the sword mechanic and gun aiming!!!
@Pichuscute
@Pichuscute 2 жыл бұрын
Would love to see a more structure oriented video on pulp too! I think it would be pretty useful, since Pulp is structured in such a weird way.
@SquidGodDev
@SquidGodDev 2 жыл бұрын
That's a great point. I feel like my bandwidth is currently stretched pretty thin since there's so much left to cover for the SDK, so what I really want to see is for someone else to come into the space and make Pulp videos haha
@SolidSnakeRL
@SolidSnakeRL 2 жыл бұрын
Was getting an error on the "isA" function so had a look at the documentation and it should be "isa" for anyone running into that.
@Markieautarkie
@Markieautarkie 2 жыл бұрын
Coming from "stricter" OOP based languages such as C#/C++, I had a tough time wrapping my head around these concepts in Lua. This video cleared up tons of confusion, so thanks for the great tutorial! One question: due to the lack of access modifiers in Lua, does this mean that any declared function will be automatically public? Is there a way to limit this scope?
@SquidGodDev
@SquidGodDev 2 жыл бұрын
Unfortunately yes, everything will be public. I think one suggested idea is to prefix methods you want to be private with underscores, but obviously that's not a very elegant solution. There is another way to implement OOP using something called closures, which I haven't really looked into, but handles private methods by I think creating a local function within another function? There are probably also other Lua libraries that implement more advanced OOP, but I haven't looked into those either.
@Markieautarkie
@Markieautarkie 2 жыл бұрын
Seems there's enough stuff to dig into, thanks for the pointers! Looking forward to future videos/devlogs 👍
@octavianscorpie6901
@octavianscorpie6901 2 жыл бұрын
Would love to see a video about dealing with tilesets ❤
@SquidGodDev
@SquidGodDev 2 жыл бұрын
And I would love to make one! I do have plans on making a video about that.
@sebastianraaphorst5133
@sebastianraaphorst5133 Жыл бұрын
Looking forward to getting my Playdate. I'm a software engineer but I've never used Lua before. I see some people are programming entirely in C or even using C++ with extern... I wonder how that would work via this style of OOP? Thanks for your great videos. You've definitely got a new subscriber from me.
@SquidGodDev
@SquidGodDev Жыл бұрын
I don't believe this exists in any form in the C API, so you only have your structs.
@kplays_6000
@kplays_6000 Жыл бұрын
@@SquidGodDev In C you can give instances of structs their own function pointers, and LCDSprite has an update and draw function pointer you can overload. Things like inheritance don't exist in C, but with some work you can emulate it
@wbutzke1
@wbutzke1 5 ай бұрын
Great video! This was very helpful. Is anyone having trouble with the timer? The projectiles shoot without any delay. I can't get the knight's ability to work as its related to the "timercallback" function. Just wondering where in the code does the projectiles delay after being shot?
@wbutzke1
@wbutzke1 5 ай бұрын
Well, the first issue was solved by using buttonJustPressed, rather than IsPressed.
@IHateYoutubeHandles615
@IHateYoutubeHandles615 8 ай бұрын
What SDE is being used in the example?
@SquidGodDev
@SquidGodDev 8 ай бұрын
Visual Studio Code
@ruolbu
@ruolbu Жыл бұрын
In case of using a dot, at 8:09 if the object library knows which object it should manipulate by the argument passed it, why do I put the very same object at the front before the dot? That seems like doing the same thing twice and only one is really necesarry
@SquidGodDev
@SquidGodDev Жыл бұрын
You could theoretically pass in a different object in instead of the same object, so it's not guaranteed to be the same. However, it's true that is pretty rare, which is why the colon syntax was created to make things easier.
@ruolbu
@ruolbu Жыл бұрын
@@SquidGodDev but I mean, what's the purpose of having self at the front then, when using the dot notation?
@SquidGodDev
@SquidGodDev Жыл бұрын
@@ruolbu The function belongs to self. Think of self like a table, and the function is in the table. If you don't have self in front, the compiler will interpret the function as a global function, which doesn't exist. You should try out these code snippets yourself and test your thoughts on them - you'll learn a lot that way.
@doomerismo9816
@doomerismo9816 Жыл бұрын
I know OOP and came to this video because for some reason it was not working in the playdate. I copypasted my code in a Lua compiller and it worked tho. The bug was just in the playdate.
@moosefreaked
@moosefreaked Жыл бұрын
Lua is confusing, class self.variables vs file local variables, child classes only seeing self.variables everything being global, nothing being straightforward. makes thinking through games have a lot of friction.
@SquidGodDev
@SquidGodDev Жыл бұрын
It is a little strange, but it starts to become intuitive pretty quickly. Feel free to ask any questions - I'd be happy to clarify.
@TonyoPet
@TonyoPet 2 жыл бұрын
Agree with @HeckBoiLmao... your videos went from a beginner demographic to an intermediate demographic. That may be your intent, but you're using a lot of terminology that goes above the average non-dev head (I shyly raise my hand). Nonetheless, your videos are really well done, I'm just losing my focus and understanding due to the prerequisite knowledge needed to watch them now.
@SquidGodDev
@SquidGodDev 2 жыл бұрын
Thanks for the feedback Tony! You're right, it was actually my intention to target an intermediate demographic. I do have some plans for more beginner friendly videos in the pipeline, and I'm thinking I might push them out sooner rather than later as I initially intended after reading this comment. Still trying to figure out a good balance!
How to Make a Simple Playdate Game
17:05
SquidGod
Рет қаралды 15 М.
Creating a Scene Manager for the Playdate
15:34
SquidGod
Рет қаралды 9 М.
The Noodle Picture Secret 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 29 МЛН
3 wheeler new bike fitting
00:19
Ruhul Shorts
Рет қаралды 43 МЛН
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 18 МЛН
Just try to use a cool gadget 😍
00:33
123 GO! SHORTS
Рет қаралды 82 МЛН
A Simpler Way to See Results
19:17
Logan Smith
Рет қаралды 96 М.
How To Fail At Arcade Games
3:01
Artindi
Рет қаралды 24 М.
Playdate - All 24 Season One games explained | VGC
23:34
Playdate Review
8:31
IGN
Рет қаралды 551 М.
Garbage Collection (Mark & Sweep) - Computerphile
16:22
Computerphile
Рет қаралды 234 М.
Everything About Playdate SDK Collisions in 7 Minutes
7:22
SquidGod
Рет қаралды 11 М.
Blueprints vs. C++: How They Fit Together and Why You Should Use Both
47:14
Making a Game You Play... WITH A CRANK???
8:46
PossiblyAxolotl
Рет қаралды 7 М.
Мечта Каждого Геймера
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,6 МЛН
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 1,8 МЛН
Как работает автопилот на Lixiang L9 Max
0:34
Семен Ефимов
Рет қаралды 16 М.
TOP-18 ФИШЕК iOS 18
17:09
Wylsacom
Рет қаралды 809 М.
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 6 МЛН