Exemplo n.º 1
0
void main() {
	loader.init();
	config1.append(slot, grp1);
	config2.append(slot, grp2);
	Events::cubeConnect.set(onConnect);
	for(CubeID cid : CubeSet::connected()) {
		init(cid);
	}
	TimeDelta time(0.f);
	for(;;) {
		System::keepAwake();
		auto startTime = SystemTime::now();
		loader.start(config1);
		for(CubeID cid : CubeSet::connected()) {
			String<32> s;
			s << FixedFP(time.seconds(), 3, 3) << "s";
			g[cid].bg0rom.fill(vec(0,0), vec(16,16), BG0ROMDrawable::SOLID_BG);
			g[cid].bg0rom.text(vec(1,1), s.c_str(), BG0ROMDrawable::BLUE);
			g[cid].bg0rom.text(vec(1,14), "Loading GRP1", BG0ROMDrawable::BLUE);
		}
		while(!loader.isComplete()) {
			for(CubeID cid : CubeSet::connected()) {
				g[cid].bg0rom.hBargraph(vec(0, 4), loader.cubeProgress(cid, 128), BG0ROMDrawable::ORANGE, 8);
			}
			System::paint();
		}
		loader.finish();
		time = SystemTime::now() - startTime;
		startTime = SystemTime::now();
		loader.start(config2);
		for(CubeID cid : CubeSet::connected()) {
			String<32> s;
			s << FixedFP(time.seconds(), 3, 3) << "s";
			g[cid].bg0rom.fill(vec(0,0), vec(16,16), BG0ROMDrawable::SOLID_BG);
			g[cid].bg0rom.text(vec(1,1), s.c_str(), BG0ROMDrawable::BLUE);
			g[cid].bg0rom.text(vec(1,14), "Loading GRP2", BG0ROMDrawable::BLUE);
		}
		while(!loader.isComplete()) {
			for(CubeID cid : CubeSet::connected()) {
				g[cid].bg0rom.hBargraph(vec(0, 4), loader.cubeProgress(cid, 128), BG0ROMDrawable::ORANGE, 8);
			}
			System::paint();
		}
		loader.finish();
		time = SystemTime::now() - startTime;
		startTime = SystemTime::now();
	}
}
Exemplo n.º 2
0
static void paintWrapper() {
    // clear the palette
    newCubes.clear();
    lostCubes.clear();
    reconnectedCubes.clear();
    dirtyCubes.clear();

    // fire events
    System::paint();

    // dynamically load assets just-in-time
    if (!(newCubes | reconnectedCubes).empty()) {
        loader.start(config);
        while(!loader.isComplete()) {
            for(CubeID cid : (newCubes | reconnectedCubes)) {
                vbuf[cid].bg0rom.hBargraph(
                    vec(0, 4), loader.cubeProgress(cid, 128), BG0ROMDrawable::ORANGE, 8
                );
            }
            // fire events while we wait
            System::paint();
        }
        loader.finish();
    }

    // repaint cubes
    for(CubeID cid : dirtyCubes) {
        activateCube(cid, taskCubes[cid].task);
    }
    
    // also, handle lost cubes, if you so desire :)
}
Exemplo n.º 3
0
void onConnect(void *x, unsigned int cube)
{
    loader.start(assetConfig);
    loader.finish();

    auto &vid = gVideo[cube];
    vid.initMode(BG0);
    vid.attach(cube);
    vid.bg0.erase(StripeTile);
}
Exemplo n.º 4
0
static void paintWrapper() {
    // clear the palette
    newCubes.clear();
    lostCubes.clear();
    reconnectedCubes.clear();
    dirtyCubes.clear();

        if(previousLearningTask != currentLearningTask){
        previousLearningTask++;
        }


    // fire events
    System::paint();

    // dynamically load assets just-in-time
    if (!(newCubes | reconnectedCubes).empty()) {
        AudioTracker::pause();
        playSfx(SfxConnect);
        loader.start(config);
        while(!loader.isComplete()) {
            for(CubeID cid : (newCubes | reconnectedCubes)) {
                vbuf[cid].bg0rom.hBargraph(
                    vec(0, 4), loader.cubeProgress(cid, 128), BG0ROMDrawable::ORANGE, 8
                );
            }
            // fire events while we wait
            System::paint();
        }
        loader.finish();
        AudioTracker::resume();
    }


    // // repaint cubes (will this paint right? If not, try repainting all of them)
    // for(CubeID cid : dirtyCubes) {
    //     activateCube(cid);
    // }

    //If the shaken timer flag is too old, turn it off again here.
    if(distractTime.isValid() && (currentLearningTask==2)) {

        TimeDelta timeSinceShook = SystemTime::now() - distractTime;
        double duration = timeSinceShook.milliseconds() / 1000;
        if((duration > 11) && isDistracted) {
            currentBackgrounds[2] = 3;
            currentBackgrounds[1] = 1;
            isDistracted = false;
        }
    }

    //update art to new task

    int j = 0;
    for(CubeID cid : CubeSet::connected()) {
        vbuf[cid].attach(cid);
        activateCube(cid);
        cbs [j] = cid;
        j++;
    }


    // also, handle lost cubes, if you so desire :)
}