Пример #1
0
void Program::render(void)
{
	SDL_RenderClear(getSDLRenderer());

	dispatch(Event(EVT_RENDER));

	SDL_RenderPresent(getSDLRenderer());
}
Пример #2
0
void Game::updateAndRender(float64 time) {
    auto platform = platformSDL;

    map->drawTiles(&camera);
    Frame spr(0);
    spr.pivot ={150,250};
    //spr.drawStraight333(sin(platform->time)*45 +45, 12);

    Frame player(2);
    player.pivot = {0.5,0.5};
    player.scale = 2.0;
    player.flags = Frame::SPRITE_FLAG_UPDATE_DEST;


    vec2 pos = {platform->width/2.0f, platform->height/2.0f};
    vec2 dir = pos - input.mouse;

    player.draw(pos.x,pos.y, dir.angle()-HALFPI);

    camera.zoom = 1.0f + 0.5f*sin(platform->time);

    if(input.left){
        camera.positionWorld.x --;
    }
    if(input.right){
        camera.positionWorld.x ++;
    }

    if(input.up){
        camera.positionWorld.y --;
    }
    if(input.down){
        camera.positionWorld.y ++;
    }

    if(input.mouseB) {
        camera.angle += 0.1;

    }
    if(input.mouseA){

        SDL_SetRenderDrawColor(getSDLRenderer(), 0, 0, 0, 255);
        SDL_RenderDrawLine(getSDLRenderer(), pos.x, pos.y,dir.x,dir.y );
    }

    Text t("Some Text!!!", {0, 150, 255});

    t.drawCenter(platform->width / 2, platform->height / 4, 2.0);
    SDL_SetRenderDrawColor(getSDLRenderer(), 255, 155, 0, 255);

    // apply input and update camera

    // update and draw map base layer

    // go through all entities and:
        // run update proc (input/thinking | animations)
        // apply movement
            // if not dynamic collidable but drawable -> draw


    // go through all bodies
        //check for dynamic collisions and solve ->dispatch event
        //check for static collisions and solve ->dispatch event
        //draw entity

    // draw map top layer

    /**
     * types of entities:
     *      ---dynamic + collidable---
     *      player
     *      pickups/weapons
     *      bullets
     *      enemies
     *      doors
     *
     *
     *      ---dynamic non-collidable---
     *      particle systems
     *      decals/blood
     *
     *      ---static collidable---
     *      walls/obstacles (solid)
     *      triggers(air)
     *
     *      ---static non-collidable---
     *      decorations
     *      lights
     *
     *
     */
}