It is currently Tue May 21, 2013 7:08 pm Advanced search

YOU / RITUAL : SPACE RITUAL (playable)

Archived Ritual Pageant Threads

YOU / RITUAL : SPACE RITUAL (playable)

Postby moonmagic » Wed Apr 11, 2012 6:36 am

Image

A game for two players. Husband and wife work together to eat, sleep, take care of a child, grow food, and maintain a spaceship on a mission to deliver oxygen gardens to stranded astronauts. Onboard computer user interface is a rhythm game, similar to Rhythm Heaven, with a little Mother 3 (if I can code it).

Don't know if this will be playable by pageant deadline; lots of other projects running concurrently.

...

So I'm picking this thing up again for the Ritual pageant; we will see!

LATEST VERSION
Last edited by moonmagic on Thu Aug 16, 2012 8:38 am, edited 3 times in total.
User avatar
moonmagic
 
Location: Seattle

Re: YOU: Music Power Family Rescue

Postby toaster » Wed Apr 11, 2012 9:31 am

Well, I hope you get time to make it. It sounds like a pretty cool idea.
User avatar
toaster
 

Re: YOU: Music Power Family Rescue

Postby Jack Sanders » Thu Apr 12, 2012 7:41 am

Small thematic criticism:

Why are they giving oxygen gardens to stranded astronauts instead of just rescuing them?
User avatar
Jack Sanders
 
Location: California, USA

Re: YOU: Music Power Family Rescue

Postby Ashkin » Thu Apr 12, 2012 7:47 am

This looks like it will turn out great.
User avatar
Ashkin
 
Location: Auckland, NZ

Re: YOU: Music Power Family Rescue

Postby moonmagic » Thu Apr 12, 2012 3:09 pm

It is possible the astronauts are not stranded, but simply in need of supplies. I just needed a job for the family to do that was Important and involved Concentration and Transmission.

Thanks for the responses, y'all. I'll try to get the observation deck ready and code the oxygen garden assembly. Need a good way to insure input matches beat windows.
User avatar
moonmagic
 
Location: Seattle

Re: YOU: Music Power Family Rescue

Postby moonmagic » Thu Apr 12, 2012 8:13 pm

Another mockup of the flight deck / assembly area:

Image

I will need to learn how to use SiON, apparently, which uses SampleData & SampleDataEvent to make sure beats stay constant. So, now that I've got graphics ready to go, my first step will be generating a basic 4/4 beat with SiON using my own mp3s. Lots to learn, we will see.
User avatar
moonmagic
 
Location: Seattle

Re: YOU: Music Power Family Rescue

Postby Terry » Thu Apr 12, 2012 8:36 pm

That looks really cool :D
User avatar
Terry
 
Location: Cambridge

Re: YOU: Music Power Family Rescue

Postby moonmagic » Fri Apr 13, 2012 6:43 am

Oy, SiON is a bit beyond me; I got it loading and playing samples when the beat triggers, but it's still all over the place because of how Flash handles external loading.

Right now seeing if I can get away with smaller samples and only visual feedback, but it is a bit beyond me to make an accurate rhythm game with Flashpunk (the only other person on the FP forums that has tried it hit a dead end too, it seems). So I might have to just loosen it up a lot and separate the dance segments from the walking around item-fetchy segments as much as possible. I will see if I can do that and still keep it feeling fair (and fun!).

Also, thanks Terry! I'm biting your style a bit, and mixing it with some NES Batman.

---

EDIT: OK, I think I've got something that will work. Since the game will only require rhythmic input during the module-building sequences, I'll just break that music up into two-measure phrases with a silent fourth quarter-beat on the second measure. I then divide the sample into fourths and allow it to restart in the last quarter-beat if necessary. This keeps the loop starting on the beat, and if one of them gets off, the next one will correct it and keep it locked to the sprite updating. My tempo might fluctuate a little, but no worse than a human drummer who is learning to drum. I can then check input from the entity that's updating the sprite / music, and I'll leave a little delay to keep it feeling good.

The music will be necessarily primitive, but should be fun in a "have you guys heard the song from Burgertime it's crazars" kind of way.
Last edited by moonmagic on Thu Aug 16, 2012 8:38 am, edited 3 times in total.
User avatar
moonmagic
 
Location: Seattle

Re: YOU: Music Power Family Rescue

Postby Ian Snyder » Fri Apr 13, 2012 2:07 pm

I've been doing a bunch of stuff with sampleDataEvent recently. I don't know a thing about SiON, but I might be able to help you with sampleData if you need it.

EDIT: How are you handling time keeping? There's a way to get perfect accuracy by looking at the progress through sampleDataEvent.
User avatar
Ian Snyder
 
Location: Kansas City, MO, US

Re: YOU: Music Power Family Rescue

Postby moonmagic » Fri Apr 13, 2012 4:47 pm

Ian Snyder wrote:I've been doing a bunch of stuff with sampleDataEvent recently. I don't know a thing about SiON, but I might be able to help you with sampleData if you need it.

EDIT: How are you handling time keeping? There's a way to get perfect accuracy by looking at the progress through sampleDataEvent.


Yes, I would love to learn about this, since I'm (not so) effectively working around it by decreasing sample length and starting over when the sprite changes. My timekeeping is totally rudimentary: Flashpunk, fixed framerate. :S Fair warning: I came to Flashpunk from Game Maker, so horrible habits abound!
User avatar
moonmagic
 
Location: Seattle

Re: YOU: Music Power Family Rescue

Postby Ian Snyder » Sat Apr 14, 2012 8:15 am

You're not going to ever get a good consistency working with events or timers in Flash (fun fact: I recently discovered there is some discrepancy in flash over whether a a second takes 1000 or 1024 milliseconds to complete, depending on what method you use. *facepalm*), I haven't actually looked into Flashpunk at all yet, so I'm not completely sure how it's handling all that.

Basically, what you're going to want to do is set up a SampleDataEvent to play all your sounds. I made this tonematrixy thing for playing sampled sounds a while back (you can see what it does here, very rudimentary), it's in some serious need of cleaning up/optimization, but it basically works.

Code: Select all
var mtx:Array = new Array();
var mList:Array = new Array();
var mc:MovieClip;
var n:uint = 0;
for (n=0; n<2; n++) {
   mtx.push([]);
   mList.push([]);
   while (mtx[n].length < 16) {
      mc = new Box();
      mc.x = mtx[n].length*25;
      mc.y = n*25;
      addChild(mc);
      mtx[n].push(0);//uint(Math.random()*2));
      mc.gotoAndStop(mtx[n][mtx[n].length-1]+1);
      mList[n].push(mc);
   }
}

stage.addEventListener(MouseEvent.CLICK,md);
function md(e:MouseEvent):void {
   var mX:int = int(mouseX/25);
   var mY:int = int(mouseY/25);
   if (mX >= 0 && mX < mtx[0].length && mY >= 0 && mY < mtx.length) {
      mtx[mY][mX] = (mtx[mY][mX]+1)%2;
      mList[mY][mX].gotoAndStop(mtx[mY][mX]+1);
   }
}

var noteIndex:Array = [0,1,0,1,0,1,0,1,2,1,2,1,2,1,2,1,
                  3,4,5,6,3,4,5,6,3,4,5,6,3,4,5,6];

////////////////////////////////////////////

const bpm:uint = 240;
const span:uint = uint(2646000/bpm);

var a:Array = new Array();
var a1:Vector.<int> = new Vector.<int>(0,false);
var a2:Vector.<ByteArray> = new Vector.<ByteArray>(0,false);
var a3:Vector.<uint> = new Vector.<uint>(0,false);

var _mp3:Sound;
var _sound:Sound;
var _target:ByteArray;
var _position:Number;
const BLOCK_SIZE:int = 3072;//2048-8192 // 3072

_sound = new Sound();
_sound.addEventListener(SampleDataEvent.SAMPLE_DATA,sampleData);
_sound.play();

function newNote(nt:uint=0,off:int=0):void {
   switch (nt) {
      case 0:
      a.push(new Note0());
      break;
      
      case 1:
      a.push(new Note1());
      break;
      
      case 2:
      a.push(new Note2());
      break;
      
      case 3:
      a.push(new BNote0());
      break;
      
      case 4:
      a.push(new BNote1());
      break;
      
      case 5:
      a.push(new BNote2());
      break;
      
      case 6:
      a.push(new BNote3());
      break;
      
      default:
      a.push(new SingleNote2());
   }
   a1.push(off);
   a2.push(new ByteArray());
   a3.push(0);
}

function sampleData(e:SampleDataEvent):void {
   var data:ByteArray = e.data;
   
   var l0:Number;
   var r0:Number;
   
   //_mp3,_position,_target,n
   for (var n2:uint=0; n2<a.length; n2++) {
      a2[n2].position = 0;
      var read:int = a[n2].extract(a2[n2],BLOCK_SIZE,a1[n2]);
      a3[n2] = (read == BLOCK_SIZE) ? BLOCK_SIZE : read;
   }
   
   for (var i:int=0; i<BLOCK_SIZE; ++i) {
      l0 = r0 = 0;
      for (n2=0; n2<a.length; n2++) {
         if (i < a3[n2]) {
            if (a1[n2]+i >= BLOCK_SIZE) {
               a2[n2].position = i << 3;
               
               l0 += a2[n2].readFloat();
               r0 += a2[n2].readFloat();
            }
         } else {
            a.splice(n2,1);
            a1.splice(n2,1);
            a2.splice(n2,1);
            a3.splice(n2--,1);
         }
      }
      
      data.writeFloat(l0);
      data.writeFloat(r0);
   }
   
   i = uint(e.position/span + 1)%16;
   l0 = e.position%span;
   if ((e.position+BLOCK_SIZE)%span < l0) {
      plyr.x = ((i+15)%16)*25 + 12.5;
      if (mtx[0][i] == 1) newNote(noteIndex[0*16+i],l0-span);
      if (mtx[1][i] == 1) newNote(noteIndex[1*16+i],l0-span);
   }
   for (n2=0; n2<a.length; n2++) a1[n2] += BLOCK_SIZE;
}


The important part is this bit at the end though

Code: Select all
   i = uint(e.position/span + 1)%16;
   l0 = e.position%span;
   if ((e.position+BLOCK_SIZE)%span < l0) {
      plyr.x = ((i+15)%16)*25 + 12.5;
      if (mtx[0][i] == 1) newNote(noteIndex[0*16+i],l0-span);
      if (mtx[1][i] == 1) newNote(noteIndex[1*16+i],l0-span);
   }


Basically, it takes the current sound position and checks to see if a beat will start in the next sampleDataEvent pass. If it will, it adds the notes it needs to play into the mix as necessary (and gives them a slight bit of silence at their start according to how long until they need to begin playing to keep on time). This is the place to do any tempo-based sprite changes (or to set a variable which will cause everything to change on the next frame so you can do it outside of the sampleEventData listener if that's important).

After that, it's just a matter of reading your samples efficiently (which this code could do better, I suspect). If I remember correctly, this implementation can play about 21 samples at once before I start to hear crackling, but to be safe I wouldn't go over eight at once. Where you get into trouble are sounds that have a long tail and end up still playing out as other sounds start.

Hopefully that helps. Let me know if it doesn't.
User avatar
Ian Snyder
 
Location: Kansas City, MO, US

Re: YOU: Music Power Family Rescue

Postby moonmagic » Sun Apr 15, 2012 4:51 am

Ian,

Thanks so much for the help and the code. It's going to take me awhile to see how it works and learn how to use it, but it's good to have a place to start, at least.

I'm not sure how Flashpunk handles timing, etc., either. My knowledge of under-the-hood stuff is really, really, limited; I'm very dependent on Flashpunk's classes, and sometimes I'm still tripped up by basic OOL stuff. Lots to learn, always!
User avatar
moonmagic
 
Location: Seattle

Re: YOU: Music Power Family Rescue

Postby Ian Snyder » Sun Apr 15, 2012 5:10 am

moonmagic wrote:Thanks so much for the help and the code. It's going to take me awhile to see how it works and learn how to use it, but it's good to have a place to start, at least.


Feel free to PM me with any questions you have! I wasn't sure how well versed you are in sampleDataEvent, and I know my code can be difficult to read for someone who isn't me anyway...
User avatar
Ian Snyder
 
Location: Kansas City, MO, US

Re: YOU / RITUAL: Space Station Thing

Postby moonmagic » Fri Aug 03, 2012 8:37 pm

I overreached with this last time and didn't get anywhere because I wanted to learn to do it "the right way". Revised plan:

This is a game where the player completes sustenance tasks on a spaceship and once a day they send out a transmission. They live on the ship with their spouse and baby. After a certain amount of time, the game ends.

I like the idea of the ship drifting against different backdrops depending on performance / what the player spends time doing.

I want to have a few different optional activities:

- Cooking (better food)
- Playing games
- Cleaning
- Stargazing
- Reading
- Gardening

I want this to be simple, so it might just be single player with NPCs that move or change activities when the player leaves the room. We'll see.
User avatar
moonmagic
 
Location: Seattle

Re: YOU / RITUAL: Space Station Thing

Postby Jasper » Mon Aug 06, 2012 1:15 am

Oh this is so gorgeous-looking!!!
User avatar
Jasper
 
Location: UK

Next

Return to Ritual Pageant [August 2012]

Who is online

Users browsing this forum: No registered users and 0 guests