bool NewGameScene_japan::onTouchBegan(Touch *touch, Event *unsured_event){
	
	auto my_player = (Player *) this->getChildByTag(0);

	if (touch->getLocation().x >= bg_origin.x + borderWidth&&touch->getLocation().x <= bg_origin.x + bg_size.width - borderWidth)
	{
		if (!my_player->isInAir && my_player->isLeft == false){

			my_player->isInAir = true;
			my_player->isMovingLeft = true;

			//my_player-> runAction(MoveTo::create(0.5, Point(x_left, size.height * 0.16f)));
			my_player->m_dir = DIR_LEFT;
			my_player->isLeft = true;
			my_player->logic();
		}
		else if (!my_player->isInAir && my_player->isLeft == true){
			//my_player-> runAction(MoveTo::create(0.5, Point(x_right, size.height * 0.16f)));
			my_player->isInAir = true;
			my_player->isMovingLeft = false;


			my_player->m_dir = DIR_RIGHT;
			my_player->isLeft = false;
			my_player->logic();
		}
	
	}

	
	return true;
}
Beispiel #2
0
  int onDraw(int width, int height) {
    logic(width,height);

    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    lxCVector4 lightpos(0,0,0,1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_POSITION, lightpos);

    m_rh.updateProjection(width,height);
    m_rh.setCameraGL();
    lxgContext_clearVertexState(&m_ctx);

    glBindTexture(GL_TEXTURE_2D,m_texture);
    glEnable(GL_TEXTURE_2D);
    
    lxgContext_checkedVertexDecl(&m_ctx, &m_vdecl);
    lxgContext_setVertexStream(&m_ctx, 0, &m_stream);
    lxgContext_checkedVertexFIXED(&m_ctx);
    lxgContext_checkedVertexAttribFIXED(&m_ctx, m_vattribs);
    lxgBuffer_bind(&m_ibo, LUXGL_BUFFER_INDEX);
    glDrawElements(GL_TRIANGLES, m_box.numIndicesTris(), GL_UNSIGNED_INT, NULL);

    glDisable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D,0);

    return 0;
  }
Beispiel #3
0
	void process(Entity& e) {
		for(auto type : componentTypes) {
			if(!e.HasComponent(type))
				return;
		}
		logic(e);
	}
Beispiel #4
0
QVariant AdapterWords::getNameLang(const spNode& word)
{
    auto l = base_->getParent(word->getID(), idtnLL_);
    if(!l) l = base_->getParent(word->getID(), idtnLK_);
    logic(l);
    return base_->getParameterNodeRef(l->getID(), idtlRef_, keyNameLang_);
}
Beispiel #5
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;

    //Logic logic(":/aggettivi.txt",  viewer.rootContext());
    Logic logic(":/indeterminativo",  viewer.rootContext());
    ExerciseVocabularyAnswer vocabulary(":/parole.txt");

    TwoSetExercise set;
    set.load("/tmp/sets.xml");

    set.print();
    viewer.rootContext()->setContextProperty("logic", &logic);
    viewer.rootContext()->setContextProperty("vocabulary", &vocabulary);

    viewer.rootContext()->setContextProperty("setexercise", &set);

    //viewer.addImportPath("qml/educazionik-framework/");
    viewer.setMainQmlFile(QStringLiteral("qml/educazionik-framework/main.qml"));
    viewer.showExpanded();

    return app.exec();
}
Beispiel #6
0
void Tutorial0_0::process_events( float dt ) {
	logic( dt );

	collision( );

	maintenence( dt );
}
Beispiel #7
0
void Gource::update(float t, float dt) {

    dt = std::min(dt, max_tick_rate);

    //if exporting a video use a fixed tick rate rather than time based
    if(frameExporter != 0) {
        dt = max_tick_rate;
    }

    dt *= time_scale;

    //have to manage runtime internally as we're messing with dt
    runtime += dt;

    logic_time = SDL_GetTicks();

    logic(runtime, dt);

    logic_time = SDL_GetTicks() - logic_time;

    draw_time = SDL_GetTicks();

    draw(runtime, dt);

    //extract frames based on frameskip setting if frameExporter defined
    if(frameExporter != 0) {
        if(framecount % (frameskip+1) == 0) {
            frameExporter->dump();
        }
    }

   framecount++;
}
Beispiel #8
0
void MainEngine::eventAddLL(const QVariant& name)
{
    logic(isInitialized_);
    fAc_->addLL(account(), name.toString());
    hideLangs();
    setCurLL(name);
}
Beispiel #9
0
void Game::run()
{
	while (window.processEvents())
	{
		float time = window.getTimeSinceLastUpdate() * animSpeed / 1000;
		logic(time);
		player->setParentToLocalR(matrix4f::buildScaling(0.0001f).rotated(vector3f(1, 0, 0), -M_PI / 2).rotated(vector3f(0, 1, 0), dir).translated(pos));
		scene->update(time);
		if (lastAnimation->weight == 0)
		{
			setAnimation(-1u);
			scene->update(1e-7f);
		}

		FrameDescription * frame = scene->getFrame(*camera);
		
		//NEWLOG("camera1: %u camera2: %u", camera, camera2);
		//frame->dump();
		std::vector<MemorySettingOrder> orders;
		ResourceManager::getInstance().getMemoryOrders(frame, orders);
		Renderer::getInstance().executeMemoryOrders(orders);
		
		Renderer::getInstance().drawFrameToSurface(frame, camera, &window);
		delete frame;
		
		window.update();
	}
	window.close();
}
Beispiel #10
0
void MainEngine::eventCreateDct(const QVariant& name)
{
    logic(isInitialized_);
    if(name.toString().isEmpty()) return;
    auto n = fLL_->createDct(curLL(), fAc_->getLK(account()), name);
    if(!n) view_->messageDctAlreadyExist();
}
Beispiel #11
0
void Level1_11_1::process_events( float dt ) {
	logic( dt );

	collision( );

	maintenence( dt );
}
Beispiel #12
0
void Logstalgia::update(float t, float dt) {

    //if exporting a video use a fixed tick rate rather than time based
    if(frameExporter != 0) {
        dt = fixed_tick_rate;
    }

    dt *= time_scale;

    //have to manage runtime internally as we're messing with dt
    runtime += dt;

    logic(runtime, dt);
    draw(runtime, dt);

    //extract frames based on frameskip setting
    //if frameExporter defined
    if(frameExporter != 0) {
        if(framecount % (frameskip+1) == 0) {
            frameExporter->dump();
        }
    }

   framecount++;
}
// Function for the single player game
void Play_SinglePlayer()
{
 clrscr();
 cout<<setw(50)<<"PiCo FeRmI BaGeL"<<endl<<endl;
 cout<<"Enter your name"<<endl;
 gets(players[playerno].Name);
 players[playerno].Admno = playerno + 1;
 cout<<"Press any key."<<endl;
 getch();
 clrscr();
 cout<<setw(50)<<"PiCo FeRmI BaGeL"<<endl<<endl;
 cout<<players[playerno].Name<<setw(20)<<"Player number "<<(playerno + 1)<<endl<<endl;
 gotoxy (60,3);
 cout<<"Score : 30";
 players[playerno].Score = logic();
 playerno += 1;
 char again,mm;
 cout<<"Do you want to play again? (Y/N)"<<endl;
 cin>>again;
 if ( again == 'Y' || again == 'y')
		Play();
 else if ( again == 'N' || again == 'n')
		{
		cout<<endl<<endl<<"Want to go to the main menu? (Y/N)";
		cin>>mm;
		if (mm == 'y' || mm == 'Y')
				MainMenu();
		else
				exit(0);
		}
Beispiel #14
0
int main(int argc, char *argv[])
{
	bool fullscreen = false;
	if (argc == 2)
	{
		if (strcmp(argv[1], "-full") == 0)
		{
			fullscreen = true;
		}
	}
	initWindow(1024, 768, fullscreen, "Space!!! :D");
	load();
	while (!keyInput.ESC)
	{
		clear();
		int i, r, g, b;
		for (i = 0; i < maxStars; i++)
		{
			r = randomNum(0, 255);
			g = randomNum(0, 255);
			b = randomNum(0, 255);
			setColour(r, g, b, 255);
			pixel(stars[i].x, stars[i].y);
		}
		update();
		logic();
		capFrameRate(60);
	}
	return 0;
}
Beispiel #15
0
    void step ()
    {
        for (Links::iterator iter (links().begin());
            iter != links().end();)
        {
            Links::iterator cur (iter++);
            //Link& link (*cur);
            cur->step ();
#if 0
            if (iter->closed ())
            {
                // Post notification?
                iter->local_node().logic().on_closed (
                    iter->remote_endpoint());
                iter = links().erase (iter);
            }
            else
#endif
        }

        logic().makeOutgoingConnections ();
        logic().sendEndpoints ();

        if (m_network.now() >= m_when_expire)
        {
            logic().expire();
            m_when_expire = m_network.now() + std::chrono::seconds (1);
        }

        m_livecache_history.emplace_back (
            logic().state().livecache.histogram());

        logic().periodicActivity();
    }

    //----------------------------------------------------------------------
    //
    // Callback
    //
    //----------------------------------------------------------------------

    void sendEndpoints (IP::Endpoint const& remote_endpoint,
        Endpoints const& endpoints)
    {
        m_network.post (std::bind (&Node::doSendEndpoints, this,
            remote_endpoint, endpoints));
    }
Beispiel #16
0
void MainEngine::hideLangs()
{
    logic(isInitialized_);
    QList<QVariant> list;
    list = fAc_->getListNamesLL(account());
    list.append(fAc_->getNameLK(account()));
    adapterLanguages_->hideRows(std::move(list));
}
static void event_handler(const ALLEGRO_EVENT * event)
{
   int i;

   switch (event->type) {
      /* Was the X button on the window pressed? */
      case ALLEGRO_EVENT_DISPLAY_CLOSE:
         exiting = true;
         break;

      /* Was a key pressed? */
      case ALLEGRO_EVENT_KEY_CHAR:
         if (event->keyboard.keycode == ALLEGRO_KEY_LEFT) {
            double pos = al_get_audio_stream_position_secs(music_stream);
            pos -= 5.0;
            if (pos < 0.0)
               pos = 0.0;
            al_seek_audio_stream_secs(music_stream, pos);
         }
         else if (event->keyboard.keycode == ALLEGRO_KEY_RIGHT) {
            double pos = al_get_audio_stream_position_secs(music_stream);
            pos += 5.0;
            if (!al_seek_audio_stream_secs(music_stream, pos))
               printf("seek error!\n");
         }
         else if (event->keyboard.keycode == ALLEGRO_KEY_SPACE) {
            bool playing;
            playing = al_get_mixer_playing(al_get_default_mixer());
            playing = !playing;
            al_set_mixer_playing(al_get_default_mixer(), playing);
         }
         else if (event->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
            exiting = true;
         }
         break;

      case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
         mouse_button[event->mouse.button] = 1;
         maybe_fiddle_sliders(event->mouse.x, event->mouse.y);
         break;
      case ALLEGRO_EVENT_MOUSE_AXES:
         maybe_fiddle_sliders(event->mouse.x, event->mouse.y);
         break;
      case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
         mouse_button[event->mouse.button] = 0;
         break;
      case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
         for (i = 0; i < 16; i++)
            mouse_button[i] = 0;
         break;

      /* Is it time for the next timer tick? */
      case ALLEGRO_EVENT_TIMER:
         logic();
         render();
         break;
   }
}
Beispiel #18
0
void ThrowTest::load()
{
    try {
        for (int i = 0; i < m_loopCount; ++i)
            logic(i);
    }
    catch (std::runtime_error& er) {}
    catch (...) {}
}
Beispiel #19
0
int main()
{
    logic(0, 0, 1);
    logic(0, 1, 0);
    logic(1, 0, 0);
    logic(0, 0, 0);
    logic(0, 1, 1);
    logic(1, 0, 1);
    logic(1, 1, 0);
    logic(1, 1, 1);
    return 0;
}
Beispiel #20
0
void callLogic(float *dt){
	static float accum = 0.0f;
	while (gameRunning) {
		accum += *dt;
		if (accum >= (1000.0f/20.0f)) {
			accum = 0;
			logic();
		}
	}
	logicIsDone = true;
}
Beispiel #21
0
 void doConnectPeers (IPAddresses const& addresses)
 {
     for (IPAddresses::const_iterator iter (addresses.begin());
         iter != addresses.end(); ++iter)
     {
         IP::Endpoint const& remote_endpoint (*iter);
         Node* const remote_node (m_network.find (remote_endpoint));
         // Acquire slot
         Slot::ptr const local_slot (
             m_logic->new_outbound_slot (remote_endpoint));
         if (! local_slot)
             continue;
         // See if the address is connectible
         if (remote_node == nullptr || ! remote_node->canAccept())
         {
             // Firewalled or no one listening
             // Post notification
             m_network.post (std::bind (&Logic::on_closed,
                 &logic(), local_slot));
             continue;
         }
         IP::Endpoint const local_endpoint (
             listening_endpoint().at_port (m_next_port++));
         // Acquire slot
         Slot::ptr const remote_slot (
             remote_node->logic().new_inbound_slot (
                 remote_endpoint, local_endpoint));
         if (! remote_slot)
             continue;
         // Connection established, create links
         m_links.emplace_back (*this, local_slot, local_endpoint,
             *remote_node, remote_endpoint, false);
         remote_node->m_links.emplace_back (*remote_node, remote_slot,
             remote_endpoint, *this, local_endpoint, true);
         // Post notifications
         m_network.post (std::bind (&Logic::on_connected,
             &logic(), local_endpoint, remote_endpoint));
         m_network.post (std::bind (&Node::doCheckAccept,
             remote_node, std::ref (*this), local_endpoint));
     }
 }
Beispiel #22
0
void Gource::update(float t, float dt) {

    logic_time = SDL_GetTicks();

    logic(t, dt);

    logic_time = SDL_GetTicks() - logic_time;

    draw_time = SDL_GetTicks();

    draw(t, dt);
}
Beispiel #23
0
void MainEngine::setAccount(const spNode& node)
{
    logic(isInitialized_);
    argument(node);

    adapterLL_->setNode(node);
    curAccount_ = node;
    view_->setNameUser(fAc_->getNameUser(account()));
    view_->setNameLK(fAc_->getNameLK(account()));
    hideLangs();
    setCurLL(fAc_->getNameCurLL(account()));
}
Beispiel #24
0
void STG::mainLoop()
{
    bool end_key_up_keyboard=false;
    bool end_key_up_joystick=false;
    painter->resetFpsCount();
    for (;;)
    {
//__android_log_print(ANDROID_LOG_DEBUG, APPNAME, "1111111111111111");
        if(receiver->IsKeyDownn(SDLK_ESCAPE))
        {
            break;
        }

		if(iteration_2 % 2 == 0 || true)
		{
	        logic();
			render();
		}else
		{
			painter->frameCap();
		}

		if(iteration_2%60==0)
			painter->resetFpsCount();

		iteration_2++;

        if(player->getHP()==0
           || enemy->getHP()==0)
        {
            if(receiver->isOuyaPressed('o'))
                break;
            if(receiver->isOuyaPressed('u'))
                break;
            if(receiver->isOuyaPressed('y'))
                break;
            if(receiver->isOuyaPressed('a'))
                break;
            if(receiver->IsKeyPressed(SDLK_RETURN))
                break;
            if(receiver->IsKeyPressed(SDLK_z) && end_key_up_keyboard)
                break;
            if(receiver->IsJoyPressed(0,0) && end_key_up_joystick)
                break;
            if(!receiver->IsKeyPressed(SDLK_z))
                end_key_up_keyboard=true;
            if(!receiver->IsJoyPressed(0,0))
                end_key_up_joystick=true;

        }
        receiver->updateInputs();
    }
}
Beispiel #25
0
void MainWidget::paintEvent(QPaintEvent* evt)
{
	tick();

	logic(deltaTime);
	render();
	renderLabels();

	HWND hwnd = (HWND)winId();
	HDC hdc = GetDC(hwnd);
	SwapBuffers(hdc);
	ReleaseDC(hwnd, hdc);
}
Beispiel #26
0
void Level1_10::process_events( float dt ) {
	logic( dt );

	collision( );

	maintenence( dt );

	if( player->pos.y + player->h / 2 > levelHeight ) {
		levelSwitch = true;
		levelSwitchTo = 9;
		levelSwentrance = 3;
	}
}
Beispiel #27
0
void nnb::GameState::update() {
	SDL_Event e;
	while(SDL_PollEvent(&e)) {
		event(e);
	}

	Uint32 currFrame = SDL_GetTicks();
	float delta = (currFrame - lastFrame) / 1000.0;
	lastFrame = currFrame;

	logic(delta);

	render();
}
Beispiel #28
0
void Level1_01::process_events( float dt ) {
	int t = heartBeat.get_ticks( );
	if( zombieTime < t ) {
		zombieTime = t + MIN_ZOMBIE_DELAY + ( rand( ) % ( MAX_ZOMBIE_DELAY - MIN_ZOMBIE_DELAY ) );
		int x = rand( ) % 300;
		enemies.push_back( new Zombie( 350 + x, Vector2D( 590.f + x, 328.f ), -1 ) );
	}

	logic( dt );

	collision( );

	maintenence( dt );
}
Beispiel #29
0
 void doCheckAccept (Node& remote_node, IP::Endpoint const& remote_endpoint)
 {
     // Find our link to the remote node
     Links::iterator iter (std::find_if (m_links.begin (),
         m_links.end(), is_remote_endpoint (remote_endpoint)));
     // See if the logic closed the connection
     if (iter == m_links.end())
         return;
     // Post notifications
     m_network.post (std::bind (&Logic::on_handshake,
         &remote_node.logic(), iter->local_endpoint(), node_id(), false));
     m_network.post (std::bind (&Logic::on_handshake,
         &logic(), remote_endpoint, remote_node.node_id(), false));
 }
void level1(double *hold)
{
	char op[2];
	double h;

	level1_5( hold);
	while (op[0] = *token, op[1] = (*(token+1)) ? *(token + 1) : 0,
		*op == '<' || *op == '>' || *op == '=' || *op == '#' || *op == '!')
	{
		get_token();
		level1_5( &h);
		logic(op, hold, &h);
	}
}