Learn Python Classes With a Text-Based Battle - OOP Tutorial

preview_player
Показать описание
I'll guide you through object-oriented programming in Python, featuring classes, objects, attributes, methods, inheritance and subclasses - all in a fun way of creating a text-based ASCII battle scene!

Find the code I made for the video here 👇👇👇

×oOo×-----------------------👽SOCIALS👽-----------------------×oOo×

×oOo×--------------------🎞TIMESTAMPS🎞---------------------×oOo×

00:00 - Classes Basics
01:39 - Character Class
05:20 - Weapon Class
06:53 - Class Inheritance: Hero & Enemy
10:24 - HealthBar Class
14:57 - Final Result

×oOo×--------------------------✨TAGS✨--------------------------×oOo×

#python #tutorial #classes #ascii #gamedev
#objectorientedprogramming #oop
#indiedev #indiegame #indiegames
#indiegamedev #pixelart #gamedevelopment
#orkslayer #orkslayergamedev
#videogame #game
Рекомендации по теме
Комментарии
Автор

utf-8: chr(9608) = ord("█") - for those who can't get it by typing "alt+0219" ASCII because in utf-8 hex it's 'e2 96 88' (©- by typing "alt+0169" is works fine). This issue may happens with using local languages keyboard.
once again: self.color = self.colors.get(color, self.colors.get("default")) - dict.get() takes the default value by the 2nd argument if missed the key.

and to get full right OOP experience, wrap all main code to some function:
def run():
name = input("Enter the name: ")

hero = Hero(name=name, health=100)
hero.equip(iron_sword)
enemy = Enemy(name="Enemy", health=100, weapon=short_bow)

while True:
hero.attack(enemy)
enemy.attack(hero)

hero.health_bar.draw()
enemy.health_bar.draw()

if not input("Press Enter to quit: "):
break

if __name__ == '__main__':
run()

\m/. .\m/
structure if __name__ == '__main__' is equal:
to C/C++:
int main( void ) {
// some code
return 0;
};

to Java:
public class Main {
public static void main (String[] args) { // some code};
}
to C#:
class TestClass
{
static void Main(string[] args) { // some code }
}

DenisTrebushnikov
Автор

holy sht, best OOP tutorial . Glad youtube recommended you 😁

kenjii
Автор

I've been learning Python for the past month and this is easily the best tutorial for Classes I've seen so far.

fieryelf
Автор

Your video is the perfect proof that when you're looking for a good tutorial video you shouldn't always care about the views on it, because there's might be a hidden gem like this. Thanks for the upload!

danielhegyi
Автор

I have watched a lot of beginner programming tutorials, and haven't been busy with it for two years. And then this video gets recommended that teaches me concepts that just wouldn't "click".

Thank you so much for creating this video, and keep it going. You deserve a lot more views and subscribers, just keep going and you probably get notices by the algorithm.

weshen
Автор

Ah! You know so many Python features. It disturbs me a little bit when some big time YouTubers seem unaware of these things. Thank you!

bow_wow_wow
Автор

Had a friend try to explain classes to me yesterday by translating some messy nested if/elif/else code I'd made into classes and telling me what he was doing. I could NOT grasp it. Doing this alongside the video, but using different terms in the flavor of the game I'm making made me understand a LOT better. Thanks!

jennytaylor
Автор

Finally i understand classes in python after 3 years thanks


Also I love the new style of your video, this time it actually fits perfect

sh_
Автор

I have been teaching classes for a couple of weeks and this is one of the best examples I've seen. I will be getting all my seniors to make this in the coming week.

samanthapennington
Автор

Absolutely best explanation of OOP for Python I have come accross (maybe its just because I understand it better in gaming terms), thank you so much for this!

corveux
Автор

Making a complicated subject easy to understand and fun while at it is incredible.

shi
Автор

This video really helped me understand to the point where I could go back and find my mistakes on my own. Thanks a lot!!

zdw
Автор

I think this is about as simple explanation as one can get for this. I still don't understand the classes fully, but this video definitely helped a lot. I just wish you were talking slower and explaining things more as you do them cuz ngl I got lost A LOT watching this.

deadspace
Автор

This video deserves a million views and you Sir deserve a million subscribers. Thanks to your video I was able to understand Python's OOP and this is coming from a person who's third language is English. Your video presentation together with your explanation made this complex topic easy to understand. Subscribed.

bernardseno
Автор

this video is so underrated for what it delivers.

Joaopedro-kpmu
Автор

If you don't learn about classes with this video, just forget about it 😂. Cleanest video about classes that I ever watched

lucaslima
Автор

I learned alot from this video about classes and being able to put it together in visual manner really helps students like us grasp it better.

Blackronin
Автор

You nailed it! I am interested in the Code Patterns. It is hard to find a tutorial, that shows you how to construct that whole thing WITH PURPOSE! Most tutorials just type a code and you habv no Idea about the WHY that and NOT that? So you filled a gap here! Thanks!

sirknumbskull
Автор

You are very good at being able to explain things in a way that is understandable; Love this video!

KoalaFruittoo
Автор

one of the best if not the best video to teach people about classes 👍👍👍

jiggyjigs