(Topic ID: 121809)

From zero to a flipping game in 1h45m with the Mission Framework

By BrianMadden

9 years ago


Topic Heartbeat

Topic Stats

You

Linked Games

Topic Gallery

View topic image gallery

IMG_0201.jpg

You're currently viewing posts by Pinsider BrianMadden.
Click here to go back to viewing the entire thread.

23
#1 9 years ago

Hi Everyone,

I'm Brian Madden, one of the creators (along with Gabe Knuth) of the Mission Pinball Framework (MPF), a Python-based open source pinball framework that can be used to create software for pinball machines with P-ROC or FAST pinball controllers in them.

In the JPOP thread last week, I was talking about how if JPOP wanted to use MPF to be the software for his machines, I believe that someone could get the code for his machine completely done in a month or two. I also said I'd take the challenge to see how far I can get with MPF with a brand new machine in one day. (i.e. I walk up to a machine I've never written any code for, and using MPF, how far can I get in a day?)

So anyway, today is that day. I have a Demolition Man that I just got, and at 7:30 this morning, I removed the Williams MPU and replaced it with a P-ROC. After that it only took me 1 hour 45 minutes to get a completely playable game up and running. (About 45min was spent just going through the manual and adding all the switches, coils, lamps, and flashers into my config, 45min to group all those together into the "logical" devices like troughs, VUKs, jets, flippers, targets, etc. Maybe 15min to fix typos and adjust pulse times and another min or two to throw together a real quick DMD attract show and game display.)

Of course there is no scoring or music or light shows, but you can play complete games.. multiple players, etc. And of course it was under 2 hours! I'm just trying to show how easy it is to get started.

Unfortunately I need to step away for a few hours, but when I get back I'll create some shots, scoring, maybe some modes, some light shows, music, etc. (And again, this is all just in one day.)

Anyway, here's a Youtube video of the (boring yet playable) game after 2 hours:

Here's a link to the entire "config" I created which powers the code in this video:
https://gist.github.com/missionpinball/5d34dcd21ce1aa906ab4

Here's the step-by-step tutorial which you can use to do the same thing on your game:
https://missionpinball.com/docs/tutorial/

I'll post more later today to show the progress. I'll also write a full blog post tomorrow with all the details, including links to all the configs, the show files, etc.

10
#8 9 years ago

Ok, back from my meeting. Next I decided to tackle the Attract Mode light show. I recorded a video of the original one before I pulled out the MPU and I recreated it in MPF. Took 58 minutes. Here's a video showing the two:

To be clear, I'm not trying to copy the "real" Demolition Man, and I will not be copying any more features from the game. Rather, I'm looking at this as if a designer came to me and said "write the code for my game. Here's my light show idea."

Latest game code here. 2 hours, 45 min of work so far:
https://github.com/missionpinball/mpf_demo_man

Next up I'll add shots and scoring.

#10 9 years ago

My claim is that if the art, dots, sounds, rules, etc. were already worked out and all I was doing was "programming" the game, I really don't think it would take more than a few weeks. I've gone on record before saying I think just about any game could be done in a month. (That's what a lot of people haven't believed, which is why I was like, "ok, fine, well let me take this game and show you how far I can get in a day, and then you can extrapolate from there.")

Again the big assumption is this isn't counting the design of the rules and the dots and all that.

It's interesting to think about in the context of that whole "WPC 2.0" thing. Obviously there's a lot more involved there in terms of licensing and all that, but from a programming standpoint, someone who knew MPF could crank out the top 20 classic B/W games in a year and then all the "code" would be open, easily tweak-able, extendable, etc. That's a topic for another thread of course, but my point is that in terms of actually programming these games via MPF, it's pretty straightforward.

#12 9 years ago

Next I added shots and scoring. The "Shots" module in MPF is where you configure series of switches that have to be hit in a certain order in a certain timeframe to count as a shot. (So, ramp enter plus ramp exit, in that order, within 3 seconds, means the ramp was made.)

Figuring out all the shots was done by throwing the ball around with the glass off and looking at the MPF log file to see what switches changed state in what order.

Once I had those set, I created a bunch of scoring events which is basically assigning points to different things.

Total time in this step: 30 min. Total time so far on this project: 3 hours, 15 min.

Video of the current progress is here:

Current game code is here:
https://github.com/missionpinball/mpf_demo_man

#14 9 years ago
Quoted from metallik:

I would actually skip the entrance requirement and just score on the made switch

Oh yeah good call. Use the entrance switch to maybe kick off sfx and light shows and stuff, but yeah, no reason to track that for the purposes of scoring or tracking shots made. Wow! Open source game programming!

#18 9 years ago
Quoted from Aurich:

But what about when you're really implementing rules, and are stacking modes, and things become complicated?

Actually that's not too bad. In MPF lots of stuff is broken down into modes. So you might have a base game mode, a skill shot, a combo tracker, a counter for super jets, a mode tracking the progress towards multiball.. so there might actually be 5-10 "modes" running even when the player thinks there's only one mode running.

So far also the "real" coding is just little things here and there. You might need to drop into Python to build some logic blocks that catch a bunch of different scenarios based on what's been completed and spit out some event, but they're pretty standalone and small chunks of code.

Really though I don't want to focus too much on "config files versus Python," rather, I want to focus on even if it's something super complex that requires a bit of Python here and there, it's still really fast to put a game together. I can't imagine any one element that would take more than a few days to figure out.

All that said, yeah, what the hell.. go ahead and throw some stumpers to me! When we're further along with MPF it would be fun to do an actual community driven version of a game. (Give us like 6 months to finish up the core MPF stuff first though.)

#23 9 years ago
Quoted from shakethatmachine:

I assume there is no trouble shooting either, which is at least 80% of the battle.

Eh, yes and no. Remember this is running on MPF which has more than 1000 hours into it. So it's not like you can write a game from scratch-scratch in 3 hours.. it's if you have MPF you already have 1000 hours of work done for you.

I mean sure, there's certainly troubleshooting that will be needed with game specific configs, and there will be bugs in MPF, but the idea is that MPF is solid and does the hard work, so there's not too much to screw up when it comes to the specifics of programming a game.

#27 9 years ago

Next I just added sound and music. I added a loop that plays while the player is waiting to plunge, and then a background track for the mode. I also added a bunch of various sound effects for the jets, slings, ramps, and targets (different sounds for hitting a lit & unlit target).

MPF's sound system is pretty advanced. You can have multiple tracks (music, voice, sfx, etc.) and each track has it's own properties (number of simultaneous sounds playing, volume & ducking, etc.) Then you map sounds to various events. All the sound mapping is done at the mode level, so higher priority modes can block sound mappings from lower priority ones and stuff like that.

Demo:

Total time for this step: 45 min. Total time on the project so far: 4 hours, 0 min.

Full game config has been updated here:

https://github.com/missionpinball/mpf_demo_man

Next? Dunno.. I think I'll maybe add a skill shot, combo tracking, and super jets? (I'm just making this up.. What do you want to see?) I could do some kind of game mode.. hit a shot to light a target. Hit that lit target. You get multiball with jackpot lit while you have multiple balls. Yeah, actually, I'll do that too I guess. Should just be a few hours for all of this.

#30 9 years ago
Quoted from Law:

Basic pseudo-complicated game for a challenge, threw in a bunch of independent timers and some objectives so that modes need access and control over shared timer and variable shot value data:

Ok, so first, if this is just the crap that you made up on the fly, I definitely look forward to programming more games with your rules!

Everything you're asking for is straightforward and I believe we can do much of it with MPF config files alone (and as they are today). Everything in MPF is "event" based.. so shots, ball movements, switches, stuff you display, starting and stopping shows, sounds.. all of it either generates or consumes events. All those events are available to be consumed via the config files also.. no Python coding necessary.

MPF has this concept of "timers" which themselves are started and stopped by events, and other events can cause them to start, stop, pause, speed up, etc. You can have as many as you need at once, counting whatever they want, at whatever speed they want, all in different states. So your game having all these timers that are all nested isn't that bad. Just break it down into little chunks and it's fine.

MPF also has this concept called "Logic Blocks" which are these things that watch for events (or series of events), in order or not (depending on the config), and then they themselves trigger other events. (So but the events they're watching and what they start can be timers.) They're like building blocks for game logic, all done in the config files, and they are how we'd do all the things like different events and outcomes based on the number of complete shots, number of lit targets, etc.

(Anyone reading this who actually might want to write their own game.. more details on this game logic stuff is here.)

So anyway.. everything you're suggesting sounds awesome and totally doable. There are a few core things for MPF on our roadmap that I'd want to build out first (for example we have an idea for managed score & shot multipliers which would be easier than writing a mode with every scoring entry entered again at 2x its lower level value) before going after this exact plan, but overall I don't see any of this being a problem. I would think it could all be done in a few days.

(And, dang, this game sounds really cool and now I kind of want it.

#31 9 years ago

Ok since the first item on Law's list is about the claw, I guess I better get that working. MPF has this concept called "Scriptlets" which are little bits of Python code you can add into your game to do things you can't do with the config files. This is what I was talking about before when I said that MPF is still easy to use even if you need to code here and there.

It took some testing to figure out which limit and position switches meant what, but once I got that figured out, creating the scriptlet was easy. This step took a total of 1 hour, 15 min, bringing the total time spent on the project to 5 hours, 15 min.

Here's a demo of the claw & elevator working:

Game code is updated in GitHub. Here's a specific link to the custom code I wrote to control the claw & elevator:
https://github.com/missionpinball/mpf_demo_man/blob/master/scriptlets/claw.py

I'll work on this again tomorrow since my original goal was to see how far I could get in a day, but due to life getting in the way I only got to spend 5 hours on it today.

#41 9 years ago

Sorry if I came off too aggressive, I'm not trying to make this a pyprocgame versus MPF thread since (1) there are already a lot of those, and (2) they're both free & open source projects, so arguing about which is better is about as productive as asking, "Which flavor of Linux is best?"

So I won't talk about how easy anything is to do because I realize that not everyone is me and I don't want to suggest that MPF is the only easy way to do things.

Bottom lines:

We're building this MPF thing.
It's free and open source.
We're very excited about it.
We started in June.
We have 1500 hours into it so far.
We have no plans to slow down.
We think it's easy to use.
We wrote a lot of documentation.
If you want to create your own pinball machine software, check it out.
If you're not a programmer, check it out anyway before you decide you can't do it.
If you don't want to use MPF, that's fine with us as long as you still create your own pinball machines and bring them to shows so we can play them!

That is all.

#47 9 years ago
Quoted from lachied:

wondering if you have any support for servos/motors included at the moment?

No. We have plans for intelligent device support for motors, steppers, and servos. They're each a bit different, but the idea is we'll have methods that expose logical things you'd want to do. (For a motor, tell it to move left or right and the device code handles the outputs, or for a stepper telling it to move to the 9 o'clock position and it keeps track of where it is, it's zero index, etc.)

For servos, we're pretty much ready to go with that but we don't know which hardware people are using. FAST has plans for a servo control daughterboard which we'll be able to use. I suspect that people using a P-ROC will add an additional USB-based servo controller? I've got a few different ones from Sparkfun and Pololu. Which ones are you thinking?

#51 9 years ago

Unfortunately I didn't have too much time to work on this today. I just put in an hour right now but I have to stop, so I wanted to post this update.

I started implementing Law's game rules, and I'm part way through Step 1.

I made it so the claw is lit when the game starts. Shoot the right ramp, diverter activates, ball to claw. Select your drop point to pick which ramp you want to light. I only have the left ramp setup so far, but you can drop it, music starts back up, ramp is lit with a countdown. (A lot of this stuff is handled by MPF.. like the diverter.. you set it up in your config file, and then whenever the elevator wants a ball it will automatically activate the diverter on the ramp entrance switch. It knows the timeouts, etc.)

Demo here:

I spent an hour on this right now, bringing my total game programming time to 6 hours, 15 min.

Everything here was done with our config files "language"

Here's the config for the mode where the claw is lit which is active when the game starts

-----
Mode:
    start_events: ball_starting
    end_events: start_mode1_acmag
    priority: 200

LightPlayer:
    mode_claw_lit_for_major_mode_started:
        lights: l_claw_ready
        script: flash
        tocks_per_sec: 4
        repeat: yes
    balldevice_elevator_ball_enter:
        lights: l_claw_ready
        script: off

LogicBlocks:
    Accruals:
        enable_the_claw:
            events: mode_claw_lit_for_major_mode_started
            events_when_complete: light_claw
        start_acmag:
            events: sw_acmag
            events_when_complete: start_mode1_acmag

SlidePlayer:
    balldevice_elevator_ball_enter:
        type: text
        text: PICK YOUR MODE
-----

Any here's the code for the left ramp lit countdown mode:

-----
Mode:
    start_events: start_mode1_acmag
    end_events: timer_mode_countdown_complete
    priority: 300

Timers:
    mode_countdown:
        start_value: 30
        end_value: 0
        direction: down
        start_running: true

SlidePlayer:
    timer_mode_countdown_tick:
      - type: text
        text: "COUNTDOWN: %ticks"
        font: small
        v_pos: bottom
      - type: text
        text: SHOOT THE LEFT RAMP
        decorators:
            type: blink
            repeats: -1
            on_secs: .3
            off_secs: .3

LightPlayer:
    mode_mode1_acmag_started:
        lights: l_left_ramp_arrow
        script: flash
        tocks_per_sec: 4
        repeat: yes
-----

Obviously a lot more to do, but I'm just showing that yes you can do timers and modes and all that just in config files.

#56 9 years ago
Quoted from Law:

Out of curiosity, and mostly because you list support for the P3-ROC, do you have any plans for supporting the P3 platform in a more comprehensive fashion? How easy is it to incorporate arbitrary peripherals or communicate with the Unity engine in the MPF? Would that sort of feature be something you guys would host?

Sorry I forgot to answer this today. (For those who aren't familiar, the P3 platform from Multimorphic is that thing where the playfield is a giant LCD screen and there's a grid of infrared beams across it that track the ball.)

EDIT: To be clear, the P3 platform is still physical pinball with physical things to shoot at.. flippers, slings, targets, ramps, toys, etc. It's just that the lower two-thirds of the playfield is an LCD screen instead of painted wood. (The flippers and slings ride on top of it.) I just wanted to clarify so people don't think the P3 is like a virtual pin cabinet. /END EDIT

We have no plans to support the P3 platform at this time. That may change of course, but I know nothing about it other than playing it at Expo. (For me I'm a "pinball" purest, and the P3 feels too much like a video game to me, so I'm going to focus the next few years on more traditional pinball development. But if someone who loves the P3 thinks MPF would be a good fit, I'd certainly help them out!)

For arbitrary peripherals, it depends what it is. Really if there's a Python wrapper for it, then we can do it. We've already experimented with standalone USB-connected LED controllers, servo & stepper controllers, and some little USB displays, and those seem like they're all easy enough to get hooked in. The real question is how well we can integrate it into our config files in a way that's logical to use. But overall MPF is very modular, with almost every component being pluggable and/or replaceable. So I think just about anything can be integrated pretty easily.

For communication with the Unity engine, we did a proof of concept a few months ago for an environment that needed to communicate with a standalone graphics rendering system, and that all seemed fine. So really as long as we can send the display system messages about what's happening or what we'd like to see on the display (what to display, positioning, size, animations, etc.), it should be fine.

Our "ideas list" has about 3 years worth of stuff on it, but we're happy to prioritize based on demand. So if anyone reading this thinks up some cool feature they're like to see, let us know!

#57 9 years ago
Quoted from epthegeek:

I mean, look at the config file Brian posted above. That's a programming language. It's pretty complex, because it has to be. Pinball code is complicated.

I like this (and what you said before) about the MPF config files really being like a programming language that we made up.

The advantage of the MPF "language" over Python (in the context of pinball) is that MPF is higher level and pinball-specific. MPF is to Python what Python is to C (and what C is to assembler). But yeah, even with a step-by-step guide to getting started, there are still multiple ways of doing everything. (Is that a shot or a logic block? What logic blocks should be in which modes? Is this a script or a show? Should this mode do two things and block what's below, or should it be two modes?)

That said, I will still try to write as many step-by-step tutorials and examples as I can and to make MPF as easy as possible for newbies while keeping it powerful and flexible enough for someone more experienced. And if people get irritated because it's not as easy as they thought, well, it's Pinside. People irritate easily.

#63 9 years ago
Quoted from gstellenberg:

The playfield in the P3 is not a giant LCD screen... just the lower part of the playfield is.

Yeah this is a better description. I didn't mean to give the wrong impression. P3 is still real physical pinball with real targets and stuff. I forgot that with virtual pin cabinets people might think that the P3 is just virtual pinball, which it's most definitely not. I like the description of replacing 20-30 single color inserts with 2m RGB inserts that also know when the ball is on them. I'll edit my original comment to point this out too.

Quoted from gstellenberg:

Suggesting that non-programmers learn to 'program' using YAML-style config files is probably fine for EM-style game rules, but is likely doing them a disservice for more complicated rulesets. I'd suggest doing your best to continue enhancing the feature-set in MPF to make programming rules in python easier, rather than spending time making the config file 'programming' more capable and therefore more complex

Yeah good point. I guess this is kind of all semantics really. What's "programming" and what's not? What's a "configuration file" versus a "program code"? We're trying to build a platform that makes it as easy as possible for people to program a full machine, including all the most complex rules they want.

So far it seems that we can do everything we need via the config files for game logic and whatnot. But if someone thinks that's a horrible idea, then they can write all their game logic in Python and just use the config files for the base hardware and device config. (The API is heavily documented at http://mpf.readthedocs.org .) They'd still get all the other advantages of MPF, and really that'd be fine by us.

Really the config files just expose stuff that would be manually created in code anyway. (Timers, logic blocks which track progress towards goals, playing display shows, sounds, or lights based on events, etc.) So they're there, use them or not. Doesn't matter to us.

As for our efforts, yeah, also a good point. We focus on adding features first, then exposing them to config files. But everything we add to MPF is available directly via the API without the config interface if people want it. We'll definitely continue to do that and not make a big deal about "no programming."

#65 9 years ago

Thanks everyone for the encouragement, feedback, and ideas. Here's an update on our future plans for our Demo Man game:

First, today I'm going to go back to working on core features of developing MPF rather than spending my full pinball time on developing this game. This exercise was an experiment to see what I could do in a day with a new machine, and now it's done.

One thing we realized from this process is that while MPF has a lot of "big" features, there are also lot of little things missing that we need as the "glue" to tie together all the pieces into a complete game. Since we really like @Law's game rules outline, we want to continue to work on building a Demo Man implementation of it, as it will be good guidance for us to make sure that we have everything we need in MPF. (And, if I'm being honest, his ruleset sounds really cool and I just want to be able to play it!)

So as we knock out features for MPF that will be useful in Demo Man, we'll continue to update our Demo Man game code and post the progress and videos here. I don't know how often those will come. Every few weeks maybe? Some of the things we really need to do in MPF are boring behind-the-scenes things or things that don't come into play with Demo Man. (Today I'm working on a better config file processing engine, and Gabe is working on our Windows installer. Wooo.)

But we'll keep chipping away at Demo Man. Once Law's ten ideas are in place, it might be cool to get some dots and sound guys (not us) to contribute some stuff (all new, nothing which uses licensed content) and then maybe we can create community-built open source pinball game code that people might actually want to play! (And since it's written in MPF with much of the config in config files, anyone who doesn't agree with anything can just download it and change the config for their own machine to whatever they want.)

One step at a time though since MPF is still version 0.15 and we haven't even gotten through Item #1 on Law's list. Stay tuned...

Brian (me) & Gabe (bulldoggk)

Promoted items from the Pinside Marketplace
4,850 (OBO)
Machine - For Sale
Lee's Summit, MO
$ 65.00
Boards
Pinball Haus
Boards

You're currently viewing posts by Pinsider BrianMadden.
Click here to go back to viewing the entire thread.

Reply

Wanna join the discussion? Please sign in to reply to this topic.

Hey there! Welcome to Pinside!

Donate to Pinside

Great to see you're enjoying Pinside! Did you know Pinside is able to run without any 3rd-party banners or ads, thanks to the support from our visitors? Please consider a donation to Pinside and get anext to your username to show for it! Or better yet, subscribe to Pinside+!


This page was printed from https://pinside.com/pinball/forum/topic/from-zero-to-a-flipping-game-in-1h45m-with-the-mission-framework?tu=BrianMadden and we tried optimising it for printing. Some page elements may have been deliberately hidden.

Scan the QR code on the left to jump to the URL this document was printed from.