#include <stdio.h>


int main() {
    printf("Hello world!\n");
    return 0;
}#include <SDL.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

#define W 960
#define H 540
#define MAX_Z 80
#define MAX_B 120
#define MAX_P 180

typedef struct { float x,y,vx,vy; int life; bool active; } Thing;
typedef struct { float x,y,speed; int hp; bool active; } Zombie;

static Thing bullets[MAX_B], particles[MAX_P];
static Zombie zombies[MAX_Z];
static float playerX = 150, playerY = 420;
static int hp = 100, kills = 0, wave = 1;
static float spawnTimer = 0, fireTimer = 0, acidTimer = 0;
static bool gameOver = false, paused = false;
static SDL_Window *win;
static SDL_Renderer *ren;
static SDL_GameController *pad;

static void rect(int x,int y,int w,int h, Uint8 r,Uint8 g,Uint8 b) {
    SDL_SetRenderDrawColor(ren,r,g,b,255); SDL_Rect q={x,y,w,h}; SDL_RenderFillRect(ren,&q);
}
static void line(int x1,int y1,int x2,int y2, Uint8 r,Uint8 g,Uint8 b) {
    SDL_SetRenderDrawColor(ren,r,g,b,255); SDL_RenderDrawLine(ren,x1,y1,x2,y2);
}
static void circle(int cx,int cy,int radius,Uint8 r,Uint8 g,Uint8 b) {
    SDL_SetRenderDrawColor(ren,r,g,b,255);
    for(int dy=-radius;dy<=radius;dy++) {
        int dx=(int)sqrtf((float)(radius*radius-dy*dy));
        SDL_RenderDrawLine(ren,cx-dx,cy+dy,cx+dx,cy+dy);
    }
}
static void text(int x,int y,const char *s, int scale, Uint8 r,Uint8 g,Uint8 b) {
    /* Tiny built-in 5x7 bitmap font: uppercase letters and digits. */
    static const unsigned char glyph[36][7] = {
      {14,17,19,21,25,17,14},{4,12,4,4,4,4,14},{14,17,1,2,4,8,31},{30,1,1,14,1,1,30},
      {2,6,10,18,31,2,2},{31,16,16,30,1,1,30},{6,8,16,30,17,17,14},{31,1,2,4,8,8,8},
      {14,17,17,14,17,17,14},{14,17,17,15,1,2,12},
      {14,17,17,31,17,17,17},{30,17,17,30,17,17,30},{14,17,16,16,16,17,14},
      {30,17,17,17,17,17,30},{31,16,16,30,16,16,31},{31,16,16,30,16,16,16},
      {14,17,16,23,17,17,15},{17,17,17,31,17,17,17},{14,4,4,4,4,4,14},
      {7,2,2,2,2,18,12},{17,18,20,24,20,18,17},{16,16,16,16,16,16,31},
      {17,27,21,21,17,17,17},{17,25,21,19,17,17,17},{14,17,17,17,17,17,14},
      {30,17,17,30,16,16,16},{14,17,17,17,21,18,13},{30,17,17,30,20,18,17},
      {15,16,16,14,1,1,30},{31,4,4,4,4,4,4},{17,17,17,17,17,17,14},
      {17,17,17,17,17,10,4},{17,17,17,21,21,21,10},{17,17,10,4,10,17,17},
      {17,17,10,4,4,4,4},{31,1,2,4,8,16,31},
      {14,17,19,21,25,17,14},{4,12,4,4,4,4,14},{14,17,1,2,4,8,31},{30,1,1,14,1,1,30},
      {6,9,17,17,31,1,1},{31,16,16,30,1,1,30}
    };
    for(int i=0;s[i];i++) {
        char c=s[i]; int idx=-1;
        if(c>='A'&&c<='Z') idx=c-'A';
        else if(c>='0'&&c<='5') idx=26+c-'0';
        else if(c>='6'&&c<='9') idx=32+c-'6';
        if(idx<0) { x += 4*scale; continue; }
        for(int yy=0;yy<7;yy++) for(int xx=0;xx<5;xx++)
            if(glyph[idx][yy] & (1<<(4-xx))) rect(x+xx*scale,y+yy*scale,scale,scale,r,g,b);
        x += 6*scale;
    }
}
static void particle(float x,float y,float vx,float vy,int life) {
    for(int i=0;i<MAX_P;i++) if(!particles[i].active) {
        particles[i]=(Thing){x,y,vx,vy,life,true}; return;
    }
}
static void shoot(void) {
    for(int i=0;i<MAX_B;i++) if(!bullets[i].active) {
        bullets[i]=(Thing){playerX+25,playerY-16,650,0,90,true}; fireTimer=0.18f; return;
    }
}
static void spawn_zombie(void) {
    for(int i=0;i<MAX_Z;i++) if(!zombies[i].active) {
        float speed=35.0f+(float)(rand()%28)+wave*3;
        zombies[i]=(Zombie){W+20, 390+(rand()%65), speed, 2+(wave/3), true}; return;
    }
}
static void reset_game(void) {
    for(int i=0;i<MAX_Z;i++) zombies[i].active=false;
    for(int i=0;i<MAX_B;i++) bullets[i].active=false;
    for(int i=0;i<MAX_P;i++) particles[i].active=false;
    playerX=150; hp=100; kills=0; wave=1; spawnTimer=0; gameOver=false; paused=false;
}
static void draw_scene(void) {
    SDL_SetRenderDrawColor(ren,8,12,28,255); SDL_RenderClear(ren);
    /* Toxic moon and ruined skyline */
    circle(760,130,57,105,160,55); circle(760,130,43,147,191,68);
    for(int i=0;i<16;i++) {
        int x=i*66, bh=90+(i*47%150);
        rect(x,300-bh,48,bh,22,29,47);
        for(int wy=0;wy<bh-10;wy+=18) for(int wx=7;wx<42;wx+=14)
            if((i+wx+wy)%3) rect(x+wx,300-bh+wy,5,7,115,105,52);
    }
    /* Acid rain */
    for(int i=0;i<70;i++) {
        int x=(i*137+(int)(SDL_GetTicks()/4))%W, y=(i*71+(int)(SDL_GetTicks()/2))%H;
        line(x,y,x-4,y+10,80,180,89);
    }
    rect(0,455,W,85,29,25,30); line(0,455,W,455,100,90,59);
    for(int i=0;i<22;i++) line(i*49,456,i*49+25,470,48,43,43);
    /* Player: cartoon survivor */
    rect((int)playerX,(int)playerY-25,31,35,48,105,63);
    rect((int)playerX+4,(int)playerY-43,23,20,221,151,103);
    rect((int)playerX+7,(int)playerY-47,22,8,35,27,25);
    rect((int)playerX+27,(int)playerY-22,31,7,35,35,38);
    rect((int)playerX+53,(int)playerY-25,25,4,220,190,117);
    rect((int)playerX+5,(int)playerY+10,8,20,42,52,46);
    rect((int)playerX+20,(int)playerY+10,8,20,42,52,46);
    /* Zombies */
    for(int i=0;i<MAX_Z;i++) if(zombies[i].active) {
        Zombie *z=&zombies[i]; int x=(int)z->x,y=(int)z->y;
        rect(x-10,y-13,27,29,61,133,70); circle(x+4,y-23,14,103,167,88);
        circle(x,y-25,3,255,230,120); circle(x+9,y-25,3,255,230,120);
        rect(x-4,y-7,17,3,38,30,28);
        rect(x-8,y+14,8,19,42,65,46); rect(x+8,y+14,8,19,42,65,46);
    }
    /* Bullets and comic impact sparks */
    for(int i=0;i<MAX_B;i++) if(bullets[i].active) rect((int)bullets[i].x,(int)bullets[i].y,13,4,255,224,111);
    for(int i=0;i<MAX_P;i++) if(particles[i].active) circle((int)particles[i].x,(int)particles[i].y,2,255,70,53);
    /* HUD */
    rect(15,14,220,14,30,35,40); rect(15,14,220*hp/100,14,70,200,75);
    text(15,35,"HP",2,255,255,255);
    char buf[80]; snprintf(buf,sizeof(buf),"BAJAS %d",kills); text(300,20,buf,2,255,245,220);
    snprintf(buf,sizeof(buf),"HORDA %d",wave); text(500,20,buf,2,255,210,70);
    if(paused) { rect(310,200,340,95,8,12,25); text(365,225,"PAUSA",4,255,235,180); text(340,270,"START PARA SEGUIR",1,255,255,255); }
    if(gameOver) { rect(250,175,460,150,8,9,20); text(350,200,"FIN DEL JUEGO",3,255,70,65); text(315,250,"A PARA REINICIAR",2,255,255,255); }
    SDL_RenderPresent(ren);
}
int main(int argc,char **argv) {
    (void)argc;(void)argv; srand((unsigned)time(NULL));
    if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_GAMECONTROLLER|SDL_INIT_JOYSTICK|SDL_INIT_EVENTS)!=0) return 1;
    win=SDL_CreateWindow("Apocalipsis Portatil",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,W,H,SDL_WINDOW_SHOWN);
    if(!win) { SDL_Quit(); return 2; }
    ren=SDL_CreateRenderer(win,-1,SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC);
    if(!ren) ren=SDL_CreateRenderer(win,-1,SDL_RENDERER_SOFTWARE);
    if(!ren) { SDL_DestroyWindow(win); SDL_Quit(); return 3; }
    SDL_RenderSetLogicalSize(ren,W,H);
    for(int i=0;i<SDL_NumJoysticks();i++) if(SDL_IsGameController(i)) { pad=SDL_GameControllerOpen(i); if(pad) break; }
    Uint32 last=SDL_GetTicks(); bool running=true, keyboardFire=false;
    while(running) {
        Uint32 now=SDL_GetTicks(); float dt=(now-last)/1000.0f; last=now; if(dt>0.05f)dt=0.05f;
        SDL_Event e;
        while(SDL_PollEvent(&e)) {
            if(e.type==SDL_QUIT) running=false;
            if(e.type==SDL_KEYDOWN && e.key.keysym.sym==SDLK_ESCAPE) running=false;
            if(e.type==SDL_KEYDOWN && e.key.keysym.sym==SDLK_RETURN) paused=!paused;
            if(e.type==SDL_KEYDOWN && (e.key.keysym.sym==SDLK_SPACE || e.key.keysym.sym==SDLK_z)) keyboardFire=true;
            if(e.type==SDL_KEYUP && (e.key.keysym.sym==SDLK_SPACE || e.key.keysym.sym==SDLK_z)) keyboardFire=false;
            if(e.type==SDL_CONTROLLERBUTTONDOWN) {
                if(e.cbutton.button==SDL_CONTROLLER_BUTTON_START) paused=!paused;
                if(e.cbutton.button==SDL_CONTROLLER_BUTTON_A && gameOver) reset_game();
                /* held-button state is polled below */
            }
            
        }
        if(!paused && !gameOver) {
            const Uint8 *keys=SDL_GetKeyboardState(NULL);
            float move=0;
            if(keys[SDL_SCANCODE_LEFT]||keys[SDL_SCANCODE_A])move-=1;
            if(keys[SDL_SCANCODE_RIGHT]||keys[SDL_SCANCODE_D])move+=1;
            if(pad) {
                Sint16 ax=SDL_GameControllerGetAxis(pad,SDL_CONTROLLER_AXIS_LEFTX);
                if(abs(ax)>9000) move=ax/32767.0f;
                if(SDL_GameControllerGetButton(pad,SDL_CONTROLLER_BUTTON_DPAD_LEFT)) move=-1;
                if(SDL_GameControllerGetButton(pad,SDL_CONTROLLER_BUTTON_DPAD_RIGHT)) move=1;
                bool padFire = SDL_GameControllerGetButton(pad,SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) || SDL_GameControllerGetButton(pad,SDL_CONTROLLER_BUTTON_X);
                if(keyboardFire || padFire) fireTimer = fireTimer;
            }
            playerX+=move*230*dt; if(playerX<10)playerX=10;if(playerX>W-100)playerX=W-100;
            fireTimer-=dt;
            bool fire = keyboardFire;
            if(pad) fire = fire || SDL_GameControllerGetButton(pad,SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) || SDL_GameControllerGetButton(pad,SDL_CONTROLLER_BUTTON_X);
            if(fire && fireTimer<=0)shoot();
            spawnTimer-=dt; if(spawnTimer<=0) { spawn_zombie(); spawnTimer=fmaxf(0.45f,1.35f-wave*0.045f); }
            acidTimer+=dt; if(acidTimer>18) { acidTimer=0; wave++; }
            for(int i=0;i<MAX_B;i++) if(bullets[i].active) { bullets[i].x+=bullets[i].vx*dt; if(bullets[i].x>W)bullets[i].active=false; }
            for(int i=0;i<MAX_Z;i++) if(zombies[i].active) {
                Zombie *z=&zombies[i]; z->x-=z->speed*dt;
                if(z->x<playerX+45 && z->x>playerX-10) { hp-=18; z->active=false; if(hp<0)hp=0; if(!hp)gameOver=true; }
                if(z->x<0) { z->active=false; hp-=8; if(hp<0)hp=0;if(!hp)gameOver=true; }
                for(int j=0;j<MAX_B;j++) if(bullets[j].active && z->active && fabsf(bullets[j].x-z->x)<22 && fabsf(bullets[j].y-(z->y-20))<35) {
                    bullets[j].active=false; z->hp--;
                    for(int k=0;k<7;k++) particle(z->x,z->y-20,(rand()%180)-90,-(rand()%140),20+rand()%20);
                    if(z->hp<=0) { z->active=false; kills++; }
                }
            }
            for(int i=0;i<MAX_P;i++) if(particles[i].active) { Thing *p=&particles[i]; p->x+=p->vx*dt;p->y+=p->vy*dt;p->vy+=190*dt;p->life--;if(p->life<=0)p->active=false; }
        }
        draw_scene();
        SDL_Delay(1);
    }
    if(pad) SDL_GameControllerClose(pad);
    SDL_DestroyRenderer(ren); SDL_DestroyWindow(win); SDL_Quit(); return 0;
}
# PortMaster build template (build on Linux with SDL2 development headers)
CC ?= aarch64-linux-gnu-gcc
CFLAGS ?= -O2 -Wall -Wextra
SDL_CFLAGS := $(shell sdl2-config --cflags)
SDL_LIBS := $(shell sdl2-config --libs)
all: apocalipsis
apocalipsis: main.c
	$(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ main.c $(SDL_LIBS) -lm
clean:
	rm -f apocalipsis
.PHONY: all clean

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: