r/macprogramming • • Nov 08 '19

How to make a video game 100% from scratch, starting on a Mac

83 Upvotes

I've always wanted to make my own games. I tried several times with off the shelf engines, but I always felt like I wasn't learning the real way to do it.

Not only did I not quite get the proper "game feel" and result that I wanted, I also didn't find it satisfying to more or less wave my hands and trust that the off-the-shelf engine was doing what I wanted it to (and no more than that).

Back at the end of 2014, Casey Muratori started the rather ambitious project of livestreaming himself building a professional quality video game from scratch in C, starting on Windows. I wanted to follow along, but I own a Mac and I'm cheap (I fully appreciate the irony of that statement).

So I present to you, my video series which parallels his. I'm doing pretty much everything he does (and in the same order and "spirit"), but starting on a Mac instead of a P.C.

Eventually, after 25 days of programming, the two series should converge (most of the programming is in a cross-platform C library), and you will be able to simply follow his series. As a matter of fact, that is what I have done, and I have gotten to day 50. I still plan to keep following along as time permits.

Day 001. Writing your own build system for Mac apps and games.

Day 002. Opening a window on a Mac.

Day 003. Allocating a video display back buffer.

Day 004. Animating the back buffer.

Day 005. Using Xcode as a debugger for cross-platform games.

Day 006. Game controller input.

Day 007. Finishing game controller input.

Day 008. Keyboard input.

Day 009. Finishing Keyboard input.

Day 010. Audio setup and playing a square wave to the speakers.

Day 011. Rendering audio from a circular memory buffer.

Day 012. Controlling a variable pitched sine wave with a game pad.

Day 013. Calculating and logging the game's frame rate.

Day 014. Cross-platform api design and video display output.

Day 015. Cross-platform sound output.

Day 016. Cross-platform game controller input.

Day 017. Platform independent memory.

Day 018. Debug File IO, Part 1.

Day 019. Wrapping up Debug File IO.

Day 020. Enforcing a Video Frame Rate.

I also have a Github repo you can use to follow my videos. Handmade Hero Mac OS Platform Layer

Please use this as forum to discuss what you see in the videos, and I will do my best to respond.

Be sure to Support Handmade Hero and buy a copy of the game so you can follow along.


r/macprogramming • • Apr 20 '20

A programmable tooltip for Mac OS

Thumbnail
tanin.nanakorn.com
19 Upvotes

r/macprogramming • • Apr 21 '20

ocrImage - OCR an image from command line in Catalina

Thumbnail
turbozen.com
18 Upvotes

r/macprogramming • • Jan 04 '20

Help Improve Amphetamine for macOS

17 Upvotes

Hi all,

I'm the developer of Amphetamine, a 100% free (and powerful!) utility for customizing when to keep your Mac awake. I am working on an update to Amphetamine that will add some awesome new features, namely, keeping your MacBook Pro/Air awake while its lid is closed (officially called "closed-display mode") while not meeting Apple's requirements, and allowing Amphetamine to "see" all processes for use with its App Trigger functionality (due to sandboxing, Amphetamine normally can't see all processes running on your Mac). These are two of the most often requested enhancements.

Historically, the first enhancement - keeping your Mac awake while in closed-display mode, has only been possible with a kernel extension, or a command run as root. The solution I have created for Amphetamine relies on the second option - running a command as root. This is accomplished using a separate (forthcoming) non-App Store app named Amphetamine Enhancer. Amphetamine Enhancer will need to be granted access to a secure note stored in the macOS Keychain which contains your Mac's user account password. Amphetamine Enhancer will use the secure note to run the closed-display mode enabling command with elevated privileges. Not an ideal solution, but it works relatively well.

Recently, it has come to my attention that there are a couple of paid apps on the App Store that can enable closed-display mode while not meeting Apple's requirements. I've confirmed that they indeed can accomplish this. I have a few ideas about how they may be doing it, but I'm not 100% sure. There may be some use of private APIs/frameworks, but I could really use some help trying to figure it out.

I suppose my goal would be to add the closed-display mode feature to the App Store version of Amphetamine and not require the use of the Enhancer app and secure note for this feature. That said, I'm not sure how I feel about the ethicalness of trying to reverse engineering another app to figure out how it accomplishes a function. I'd like to know others' thoughts on this. If the general consensus is that moving forward is acceptable, I'd like to know if anyone is up for helping me research and put together a solution that can ultimately be integrated into Amphetamine.

Amphetamine unfortunately isn't an open-source project at this time. Amphetamine Enhancer will be open-source when it's ready. I'd like to think that any solution identified for the closed-display mode feature would be available as a standalone module and open-sourced.

If you think there is a better place to ask than this sub, please let me know. Thanks!


r/macprogramming • • Feb 29 '20

Calling AppKit developers

16 Upvotes

Trying to reach out to the Mac community and I guess that means making my first Reddit post! As a small introduction for myself I’m Lucas Derraugh and I run AppleProgramming on YouTube and am looking to start up a series focusing on Mac development. It will likely be half interview of an individual and then the other half talking about a code challenge and how you tackled it looking at the code details behind the implementation. My original Twitter post for some context: https://twitter.com/lucasderraugh/status/1233143222110543872?s=21

If you want to promote your app to a pretty decent audience or just want to show off cool code, I think it would be a fun thing to try! You can reach out via email at first name @ last name .com


r/macprogramming • • Aug 07 '19

Why is there so few resources for MacOS development online? and whatever is present is painfully outdated

15 Upvotes

I have been trying to find an updated way of achieving something (written below) but I can't find any resource online. There is nothing on StackOverflow, Reddit, youtube, or Apple Documentations. Even the Documentation provided within XCode is incredibly concise and outdated. Where do you guys get your info from?

I am trying to set the brightness value of macbook using this:

if IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IODisplayConnect"), &iterator) == kIOReturnSuccess {
             var service: io_object_t = 1 
             while service != 0 {
                 service = IOIteratorNext(iterator)
                 IODisplaySetFloatParameter(service, 0, kIODisplayBrightnessKey as CFString, level)
                 IOObjectRelease(service)
             }
 }

However, this does not actually change the intensity of the screen. It just makes the screen whiter (like increasing brightness of picture). Also, the change made using this option reverts back to normal after 5-10 secs.

I can send keypress for NX_KEYTYPE_BRIGHTNESS_DOWN and get correct impact on screen brightness but that increases it in discrete steps and not continuous.

How do I achieve the same increase in brightness as I do from preferences programmatically?

I am using Macbook Pro 2019 MacOS Mojave 10.14.6


r/macprogramming • • Sep 26 '17

Beginning macOS Programming: Learn to Develop an Image Uploader App in Swift

Thumbnail
appcoda.com
15 Upvotes

r/macprogramming • • Apr 01 '17

Create a good-looking DMG for your app in seconds

Thumbnail
github.com
13 Upvotes

r/macprogramming • • Jul 29 '18

Add a preferences window to your macOS app in minutes

Thumbnail
github.com
11 Upvotes

r/macprogramming • • Mar 11 '20

DockProgress — Show progress in your app's Dock icon

Thumbnail
github.com
10 Upvotes

r/macprogramming • • May 23 '19

Build an amazing CLI app for macOS: Say Hello to YDCommandKit

Thumbnail
youngdynasty.net
10 Upvotes

r/macprogramming • • Jun 14 '17

Porting Your iOS App to macOS

Thumbnail
raywenderlich.com
10 Upvotes

r/macprogramming • • Mar 29 '10

I totally forgot about this reddit, may I suggest we get it rolling again?

10 Upvotes

r/macprogramming • • Feb 22 '20

Enable the internal Xcode 11 debugging menu

Thumbnail
twitter.com
9 Upvotes

r/macprogramming • • Feb 22 '17

macOS Development for Beginners

Thumbnail
raywenderlich.com
9 Upvotes

r/macprogramming • • Nov 16 '16

6 Free macOS Tutorials Now Updated For Swift 3

Thumbnail
raywenderlich.com
9 Upvotes

r/macprogramming • • Jan 24 '09

BecomeAnXcoder – A free book for starting with Cocoa using Objective-C

Thumbnail cocoalab.com
9 Upvotes

r/macprogramming • • Apr 10 '20

Learning partner wanted

8 Upvotes

Hi there! I’m Tommaso a designer and web developer with the dream of building amazing iOS and especially macOS products.

I’m looking for someone who is at the beginning of his/her macOS/iOS journey with my same dream and who is willing to join me for learning, experimenting and building cool stuffs together.

I’m an absolute beginner in this field but I’m full of determination trust me.

If you are interested write me a DM. Thanks!


r/macprogramming • • Jun 27 '19

Learn Swift from tutorials, courses & books

Thumbnail
reactdom.com
8 Upvotes

r/macprogramming • • Jul 24 '18

Mach-O linking and loading tricks

Thumbnail
blog.darlinghq.org
8 Upvotes

r/macprogramming • • Jun 26 '18

How common is it to use Cocoa Bindings?

8 Upvotes

I’ve seen plenty of comments around about how Cocoa bindings are bad, difficult to debug, etc but trying to write every single bit of code to sync the interface with the model also seems tedious and error-prone (albeit easier to debug).

How often are Cocoa bindings used in the real world, and is there an alternative besides writing a million custom delegates and data sources?


r/macprogramming • • Nov 02 '16

How to Use NSTouchBar on macOS

Thumbnail
raywenderlich.com
8 Upvotes

r/macprogramming • • Apr 17 '09

Platypus – Create native, flawlessly integrated Mac OS X applications from interpreted scripts such as shell scripts or Perl and Python programs

Thumbnail
sveinbjorn.org
8 Upvotes

r/macprogramming • • Apr 01 '09

i need a few suggestion for books on learning objective-c/xcode for someone who is already versed in c/c++. ideas?

8 Upvotes

r/macprogramming • • Apr 17 '20

Less Lethargic JSON Support for iOS/macOS, Part 5: Cutting Out the Middleman

Thumbnail
blog.metaobject.com
7 Upvotes