Freecity Patrol
This is my first time genuinely making a game in Python, and I have no idea how to start. I'll probably be using pygame because everyone uses it, but I'll see how it goes.
My goal is to have some fun this week and finish a project for freakin once.
Wish me luck!
github.com/Aimarekin/freecity-patrol
Awards
Files
File | Uploader | Date |
---|---|---|
logo.png
Game's logo |
Aimarekin | 2021/03/29 15:57 |
Diary Entries
Day 1: Coming up with an idea
The next morning, I remembered that notification. I was bored, so I decided to take a look and read it. I didn't have much to do this week, and I had just come up with an idea that I thought would be funny, so I created my "BazookaCop" entry. The idea was simple: you're an officer, there are cars and streets below and you shoot cars that don't obey traffic law with your bazooka. But just after creating the entry and actually thinking about how I'd implement the mechanics, I noticed it could be a bit complicated and difficult to implement.
So I came up with a different idea, managing a police department. You've got officers, a city and, most importantly, emergency calls to respond to.
You start with a city map, a safety meter, some money and a couple of officers. After a couple of seconds, a call shows up in your screen. You then have to select any of your officers, dispatch them to the call and wait for them to solve it. Unattended calls decrease safety. Different calls will be varyingly severe, and will require more or less time to solve, and decrease safety by different amounts. The more officers you send to a call, the quicker it'll be resolved. Calls will eventually disappear if left unattended, but will greatly decrease safety. Solving calls will give the player money, which can be used to hire officers.
Progressively, more calls will appear, and you'll have to hire more officers. Officers who assist many calls will gain experience, which will help end calls faster. After some time, officers will retire too, so you'll have to hire more to fill the gap. The game ends when safety reaches 0.
I hope I'll be able to finish this project and submit a good game. Until then, good luck to all participants!
Day 2: Slower than I'd like to be, made a logo
I've decided to go with Arcade. It just looks so much easier and many of the things I'd like to do, like tinting images, have explicit functions, rather than pygame, where I'd have to mess with blending and stuff.
I've also made a logo. I'm not sure what I want the main screen to look like. Maybe just a color gradient. I'll see.
Haven't done much. I really need to get going!
Day 2: I DID IT. ASPECT RATIOS. Well, not really.
Every engine I've used so far had some sort of automatic scaling for when the user resized their window. But, python? Yeah, forget about any kind of help.
This was a pain. There was absolutely 0 documentation about how to implement this on Arcade, which is the module I'm using. I want my game to keep it's aspect ratio no matter how the user resizes the window, by adding black bars to the sides. It took me 45 minutes for my brain to use 5% of it's processing power and realize this:
(orig height/orig width) = (new height/new width) Therefore (orig height/orig width) * new width = new height (orig width/orig height) * new height = new width
So simple, but my small brain kept searching for complicated equations, algorithms and formulas that were just not necessary.
Afterwards, I spend a good time looking at the docs. That set_viewport function wasn't even that complicated. But my brain refuses to believe things can be simple. I'm kind of contradicting myself now, aren't I?
That was not the end of it. This is the code I made:
if width <= height: # Width is smaller or equal r_width = width s_width = 0 r_height= math.ceil((500/800)*width) s_height = math.floor((height - r_height)/2) self.set_viewport(-s_width, r_width+s_width, -s_height, r_height+s_height) print(f"\nResized to {width}, {height}.\nWidth is smaller.\nResult is {width}, {(500/800)*width}\n") else: # Height is smaller print(f"\nResized to {width}, {height}.\nHeight is smaller.\nResult is {(800/500)*height}, {height}\n") r_width = math.ceil((800/500)*height) s_width = math.floor((width - r_width)/2) r_height= height s_height = 0 self.set_viewport(-s_width, r_width+s_width, -s_height, r_height+s_height)
It basically tries to make the content inside as big as possible within the space available in the window. But since I'm not accounting for aspect ratios in the conditions, it doesn't detect when it has to switch modes very well. Also, making the width smaller breaks it and doesn't correctly center or scale the content. Here's a picture to embarrass myself.
TL;DR: Two days and I can't even handle aspect ratios. I better calm down and lower expectatives. Good luck to everyone!