18 Video Views·Apr 22, 2025
Learn to create an idle click style game in the model of the classic and popular adventure capitalist style of app by using python and pygame!
This is episode 3 in a 4 part series that covers start to finish how to create this entire game from scratch! We cover the basics of python and pygame code creation while also diving into more advanced programming concepts in this series!
Ep.1 : https://www.youtube.com/watch?v=aKP490xRStY - Draw the Board
Ep. 2 : https://www.youtube.com/watch?v=hzf7NQf3riQ - Player Controls
Ep. 3 : https://www.youtube.com/watch?v=lyaKsvefdaQ - Managers
Ep. 4 : https://www.youtube.com/watch?v=MtrLVy4I7uE - Upgrades
Episode 1 covers the basics of defining the board game space, as well as importing the module, defining screen dimensions and creating a library of colors. Additionally we create a function to draw the tasks onto the screen rather than defining each individually. We then cover conditions for exiting out of the game as well as displaying text for the value of each event onto the buttons.
Episode 2 in the series handles the actions from the player of actually clicking on each button and updating the money or score the player has accumulated so far! This includes getting the position of the mouse upon clicking and checking if the coordinates are aligned with any of the defined event buttons.
Episode 3 includes the drawing of the buttons for purchasing more of each event commodity and displaying the manager buttons that would allow the player to automate each task. Additionally we block transfer (blit) text onto the screen showing the cost of each element and round all numerical value to only two decimal places.
Episode 4 concludes the series by handling the actual purchase and automation of each task when the managers are purchased, as well as increasing the value of each event and the cost of purchasing more of each event.
Thanks for checking the video out and be sure to be on the look out for more great content and check out the channel for dozens of useful python tutorials like this!
https://www.youtube.com/channel/UCV5Ab39YnXvTZ6Grar9URxQ
Be sure to like, subscribe, and leave a comment on what you found useful or what you'd like to see next!
Thanks!
what's going on you guys welcome back to
the channel today's video is going to be
a continuation in our building an
adventure capitalist style idol clicker
game using python and pygame and if you
missed the first two episodes of the
video we did get to a point where you
can click the different tasks they run
at different speeds we draw everything
onto the screen and we give you more
money
as you go through and run different
tasks so i do recommend checking out the
first two if you want to follow along
click for click but if you're just here
for the concepts in this video that's
cool too so let's get right into it
um as i said we have created
this game where you can click these five
different tasks they run different
speeds you get different money per task
that's really cool but a big piece of
the adventure capitalist and like all
these idol clicker games
is there are buttons where you can buy
more of each product or you can buy
managers to automate your
stuff so that's what we'll do in this
video is we'll draw those buttons onto
the screen
and set up a system where you can kind
of advance the game and get
progressively more money as as you go
about it so we already draw a lot on the
screen in this draw task so i'm thinking
to draw the buttons on
let's create a new function you could
absolutely like
continue modifying the draw task
function if you want but you're going to
get to a point where you have to pass in
like 12 variables and you get like six
things back and i think since this is
kind of a separate task and separate
idea i like the idea of doing it in its
own function
so let's take a look at it since these
are going to be buttons in the same way
that we called the task above we gave it
a name so that we could return it let's
just anticipate needing to return both
of these
and so we'll say
color button so that'll be this will be
the first one that lets you buy more of
each color and let's say that's going to
be a rectangle
pygame.draw.rect just like before
and we're going to put it on the screen
and we're going to make it a color so
just like before we'll want to pass in a
color variable that'll be one of the
things we need
another reason i really like thinking
about this in terms of like a function
and writing the function first is it
points out to you what variables you
need to pass in and what you can expect
to get back out so there's no right and
wrong way of doing it as long as it
works in the end
but i like doing it this way so
we're going to pass in color and then
before we pass we just need to change a
y coordinate right well i'm thinking for
these we're just going to change an
x-coordinate so we'll make the green
buttons all the way on the left of the
screen
and we'll have the purple buttons all
the way on the right and we'll space
them out that way
so we're going to pass in an
x-coordinate but then for these buttons
for the top row of buttons i think we'll
put them at 340 that should be below all
of the tasks
and then we'll just make it 50 wide and
30 tall so that's a good size button and
we'll have to pass in an x coordinate
and that'll be the first button and then
let's go ahead and say we're going to
want to display on the button how much
it costs to buy that
so we'll call that color cost and i
think what that means is we're going to
need to pass in a variable
that's cost so we'll keep track of how
many are owned and how many um how much
it would cost to buy the next one in the
outside world so we'll pass that in
and we'll do font.render because this is
going to be text and we'll do string of
the cost and i think just like before
i'm going to do this with any text that
we display that could be fractional i'm
going to round it just preemptively so
it doesn't give us issues later on
and we'll make this black text because
it's going on a colorful button and
that'll be a little bit easier to read
and then let's do screen dot blit
and let's put
color cost right on the screen
spell it right would help
and we are going to screen. cost and
then let's use that x chord again and
just scoot it to the right a bit so it's
not fighting
for screen space and then we'll put just
a little bit below
the start of the rectangle so it should
pretty much be in the middle of the
screen here
and let's go ahead and say for the
manager i think it only makes sense to
display a button to let you buy the
manager if it's not already purchased
so we'll pass in a variable called owned
that'll say whether or not you've bought
the manager for that color already
and if it hasn't been purchased that's
when we'll display what i'll call the
manager button so we have the color
button and the manager button
and essentially everything else will be
just like what we had before so i'll
actually copy this save us a little bit
of time and all we'll really need to do
it'll still be on screen it'll still be
on the color
and it'll be at that same x coordinate
let's just move it down the screen a
little bit so we'll put it
right underneath that first button and
then we'll call this manager cost
instead of color cost we'll scoot it in
and
actually we should probably call this
manager
text because i think since we're already
using a variable called cost and we have
to pass another variable in
we'll want to pass in a
manager cost instead of just cost for
the manager
all right so i think i like that
and let's go ahead and pass in
manager text
and then just like before 350 we want to
move that down a little bit so we'll put
it at 410
and i think that will draw
a cost rectangle and a manager rectangle
on screen with whatever cost we pass in
so
you can see right here i think we need
to create three new variables for this
function as well
for um
for
using these and calling them but we just
know right away too we're going to
return the color button
and the manager button okay so
to do i think that'll do it let's go
ahead and create cost owned and manager
cost for everything
up in our game variables section so
um this is getting pretty
long the game variables so i'll make a
new one that's draw buttons function
and we're going to have green cost which
i think will start out just charging
what we'll start out charging what the
value of it is
and again you can mess with this as much
as you want but then to start none of
the managers are going to be owned so
we'll make that false
and then we'll make the
green
manager
cost
let's make it a hundred you want the
manager cost to be significantly more
than like just buying one more of each
item
because uh
it's it's gonna be like a one-time
purchase but then once you've bought it
like it's running the thing for you so
it should be difficult to buy them um
the first time i think so that's why
i'll make the managers all like
kind of quite a bit more expensive than
just buying like the next of each thing
but so okay we go green then we go red
then we go orange
and again um once we get into the code
of actually like
what happens when you click on each of
these things and buy them that's when
we'll start playing around with
like how to also make it so that it
costs more to buy more of the thing
as you've purchased 10 20 100 of them it
should get more expensive to buy them
because you're also going to be
upgrading the value of each task
so
let's see here
i think we'll go from for the manager
costs
we'll just go one two three four five to
buy the initial one they'll all be false
um to start because none of the managers
will have been purchased
but let's start getting as you buy the
more expensive managers let's make it
really to where like you feel that cost
so we'll say four thousand and ten
thousand and that may seem really high
because like to start off you have to
click every button to get every dollar
but try to think like purple manager is
the highest thing you can buy in this
game that we've created so you want it
to be like an achievement
okay so we've created all those
variables
and we've created our function to draw
the buttons but we haven't actually
called drawing the buttons yet so
let's see we're going to be getting
color button and manager button back
so
let's say green color
uh we'll just say green button that's
probably easier
i'll say green by
and then
green
manager by
is going to be equal to and we're going
to get that back from draw buttons
and then we are going to give this guy
green we are going to give him an x
coordinate of
let me see what i went with 50.
we are going to pass in the green value
we are going to
pass in
draw green
we are going to pass in green length
and we are going to pass in
green
speed
nope that's the task i passed in the
wrong things one second
we are going to do green sorry about
that i passed in the
variables for the task drawing
so we're gonna give it green we're gonna
give an x coordinate of 10
and then the variables we just made
which are green cost
green
manager cost
and then we are going to give it
green owned
so whether or not the manager has been
purchased
and before i think before i copy that
five times let's just run this and make
sure the buttons show up where we expect
them on the screen
yeah so something funky is going on here
green manager by
manager button did i not call it manager
button
if not
owned hmm
i don't see a problem with that
[Music]
button let me see
the problem may be
that um
the problem may be that
if it is owned then manager button just
appears empty
so let's say
screen.black
and let's let's call the manager button
right here in the beginning
so just in case it's not processing this
and it's trying to pass it back let's
see if that works
okay well we get
one button so we're close
get rid of this i don't want to tear
apart this code i feel like this should
do it
turn color button manager button manager
buttons right there
rectangle
i'll get rid of the if not owned until
we write the code for purchasing it and
we'll take a look then it may be that
there's no way to
purchase it today so it doesn't like
that
um
so we'll see
but there we go the other thing is the
manager cost is showing up as zero
but we should be passing in
let me see
green cost green manager costa green
owned i put those in the wrong order
dang it all
so that was our error there we passed in
the wrong variables in the wrong spots
so it this is a really important thing
when you write multi
multi-variable functions in python you
have to make sure you pass them in in
the right order so there we go it's cost
owned then manager cost
now i'm pretty sure that was the reason
we couldn't
we couldn't use this because it wasn't a
boolean so it wasn't executing properly
let's take a look now
all right i feel a little bit better
about that let's go ahead real quick and
copy that in four times for the rest of
the buttons
and then
we will call it a video here and we will
take a look at actually finishing things
out in the next video so this is
gonna be red
red red and we want to scoot it to the
right
by i think
60 so we'll make this 70.
this now will be red cost
red owned
and red manager cost
we gotta do that
orange i'm gonna go ahead and copy the
text that'll speed things up a little
bit
again i think i said this in the past
videos um you can definitely set up for
loops like if you were to create a
list of your colors
um you could definitely write some for
loops that would be pretty slick code
that would
go through and do some of this code that
we do like five times for the five
different colors and you totally could
use the same code
to do it five times over
sort of in the same way that we created
generic functions to do a lot of this
code
code like draw buttons and draw the
tasks five times you could do the exact
same thing
with all of these lines of code but it
does get a little funky like if you want
to
um
draw a rectangle onto the screen but you
need to change the name of that
rectangle with every iteration that can
get a little weird
plus this is a really easy way to look
at it
and just see it all in the same place so
then 190 250 keep scooting at 60 to the
right let's see if that draws 10 buttons
on the screen for us so there we go we
see the values we see the cost of the
managers
um
you can play around with spacing i think
i'm going to move the
manager text a little bit to the left
actually so we'll say just
x plus 2 because that 10 000 got cut off
a little bit yeah i think that looks
better and let's just real quick let's
throw in one last thing on this video
let's actually put in text that says
like what you're buying there
so let's make uh some text that i'll
call
buy more and this will just go above
those buttons where you buy stuff and
let's say font dot render and then buy
more
like that
and we're gonna do true and white okay
and then we're gonna blit
that guy
and we're gonna put it
for location we will put it right above
those buttons so 10 315 is right about
there
and let's copy that and let's
go ahead and do another one that we can
call by managers
and instead of buy more we will say by
managers and then we just need it to go
down a little bit so we'll put that at
380.
that's a little bit lower down on the
screen and let's take a look at that
okay oh well it still says buy more
because i didn't
tell it to do by managers
alrighty hopefully that fixes that buy
more by managers so the buttons don't do
anything yet but our game is playable we
drew those buttons onto the screen we
did it in a function so if we do need to
modify those or use them in the future
we have one
generic function so hopefully you found
this cool hopefully you're enjoying the
series
if you did be sure to leave a like
subscribe to the channel it helps me out
a ton and if you have any questions on
what you saw today or want to be sure
you see something specific in the future
just let me know about in the comments
below and be on the lookout for the
fourth and final piece of making the
game where we'll actually make it to
where buying more and buying the
managers do increase the value of the
buttons and automate each task for you
so
keep an eye out for that check out the
rest of the content on the channel and
as always good luck with your code and
thanks for watching thanks bye