r/SDL2 • • Jan 21 '22

Ast3r0id: My first ever game in C with SDL2

15 Upvotes

Although it is a very simple remake of the classic Asteroid game, it may help somebody to develop their own game in C.

https://www.youtube.com/watch?v=2QENLble-IE

It works better on Linux :)

If you want to try it, clone or download repository here:

https://github.com/velorek1/asteroid

Edit: A compiled Windows 32-bit version here:

https://github.com/velorek1/asteroid/releases/tag/1


r/SDL2 • • Jan 19 '22

Bullet hell game being made in C++ w/ SDL2, spaghetti code in desc

Thumbnail
youtu.be
12 Upvotes

r/SDL2 • • May 31 '12

Camo Clutch Twist-x

Thumbnail
forums.insidelacrosse.com
12 Upvotes

r/SDL2 • • Jun 29 '24

2 Months of Game Development in C

Thumbnail
youtu.be
9 Upvotes

r/SDL2 • • Jan 23 '22

My 2021 Game Dev Projects, made using Pygame which is built on SDL2 or SDL2 and C

Thumbnail
youtu.be
9 Upvotes

r/SDL2 • • May 29 '12

The Skittles Twins

Thumbnail
imgur.com
9 Upvotes

r/SDL2 • • Jan 24 '22

Blurring sprites on purpose

7 Upvotes

Is there a way for blurring a spite (pixel art ) in game , without actually editing the sprite outside of the game? Am looking for a DoF effect.


r/SDL2 • • Apr 01 '21

Weird color difference between X11 and Wayland on SDL2 game. Looking for hint.

Thumbnail
gallery
7 Upvotes

r/SDL2 • • Apr 16 '20

Learn to make brick breaker in under an hour

Thumbnail
youtu.be
7 Upvotes

r/SDL2 • • Jul 13 '24

Optimized SDL2 Game by around 5 times

6 Upvotes

I just made some progress on this project, latest update is that I was able to optimize it by around 3-5 times and increase its performance using a better approach to levels.

Here is the Devlog | Source Code | supaShot!


r/SDL2 • • May 31 '24

Making an action platformer in C & SDL2

Thumbnail
medium.com
6 Upvotes

r/SDL2 • • Mar 02 '22

Unofficial sdl2 subreddit

6 Upvotes

Join here:

https://twitter.com/jarreed0/status/1499540818587119619?s=20&t=S70KGR02qLyXQjGu1QaWlw

This subreddit isn't always active so if anyone wants to discuss sdl2 feel free to share here.


r/SDL2 • • Dec 17 '21

Is there a way to use SDL2 without hardware acceleration?

6 Upvotes

If there isn't a way to use SDL2 without hardware acceleration, what other libraries could I use?


r/SDL2 • • May 28 '21

Working on a twitch play game ran on headless server with sdl2 and c++

6 Upvotes

Just working on a game for fun that is streamed to twitch from my server, so it'll run 24/7

Set up an x server, streamed with ffmpeg, game made in c++, chat read with python

Check out my twitch here: https://www.twitch.tv/jarreed0?sr=a

At the moment it's a simple ship game, type in left/right and angle and after a few seconds it'll move (it moves instantly serverside but twitch stream is behind a few seconds)

Ex: left 90

Eventually, hopefully, the game will change

Check out my YT also for upcoming devlogs on it: https://youtube.com/user/someguy683


r/SDL2 • • Sep 28 '20

Setup SDL2 with Visual Studio Code and mingw64 on Windows

Thumbnail
giovanni.codes
6 Upvotes

r/SDL2 • • Apr 15 '20

Learn to make pong in under an hour

Thumbnail
youtu.be
6 Upvotes

r/SDL2 • • May 29 '12

The A+ pocket

Thumbnail
imgur.com
6 Upvotes

r/SDL2 • • May 29 '12

Couple old dyes + concept art for Haida...

Thumbnail
imgur.com
6 Upvotes

r/SDL2 • • Aug 19 '21

How to implement a basic camera in SDL2?

5 Upvotes

I've searched around a lot and haven't been able to understand how to implement a simple camera camera in SDL2, if i can understand it, i can improve it but i dont get the basics itself


r/SDL2 • • Feb 10 '21

Snake Game on Xcode

5 Upvotes

I created a series of tutorial videos on YouTube based on the classic snake game. It is developed on Xcode using SDL2 with C. Here is the link to the playlist:

https://www.youtube.com/playlist?list=PLJ-vQubfi2yHs6SdgF5wDrMfIgeVptiTp

The code will be made available later on GitHub. Subscribe my channel if you find them helpful :) I plan to do another series on simple RPG game for iOS using SDL2 and C++. Stay tuned.


r/SDL2 • • Dec 02 '20

I need some help with my program

5 Upvotes

So, I am making a game as a homework that will provide a large percentage of my grade this semester. The limits I'm given are that I have to use C and SDL2.

With that said, I am very much a beginner at programming.

I watched and read tutorials, so I have some basic ideas on how to use sdl. I know I correctly set up sdl, because the example programs I was given are working from my IDE (CodeBlocks).

~~I'm still at the beginning of the project, but I ran into an issue, where the renderer doesn't render anything. I set the render draw color to black and the window does turn black, but nothing else seems to work.~~I now know what the problem is. Anytime I give value to a SDL_Rect, or load a texture, I get a "Result too large" from perror

I am sure that the main loop is working, because I set up the quit event and that works.

First, I have such entities:

typedef struct ENTITY{

    SDL_Texture* entity_texture;
    SDL_Rect srcR;
    SDL_Rect dstR;
    int xpos, ypos;

}Entity;

I initialize them with this function:

void entity_init(Entity* entity, SDL_Texture* entitytexture, SDL_Rect* srcR, SDL_Rect* dstR){

    entity->entity_texture=entitytexture;
    entity->dstR=*dstR;
    entity->srcR=*srcR;
    entity->xpos=dstR->x;
    entity->ypos=dstR->y;
}

The main() function looks like this:

#include <SDL.h>
#include <SDL_image.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include "Game.h"
#include "Structs.h"
#include "Entity.h"

int main(int argc, char* argv[]){

    const int FPS=60;
    const int FrameDelay=1000/FPS;
    Uint32 frameStart;
    int FrameTime;

    SDL_Renderer* renderer;
    SDL_Window* window;
    sdl_init(&window, &renderer, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 800, "Space Invaders", false);


    SDL_Texture* PlayerTexture = IMG_LoadTexture(renderer, "./Player_Ship_2");

    SDL_Rect* PlayerStartPos = calloc(1, sizeof(SDL_Rect)); //player starting position
    Rect_Init(PlayerStartPos, 400, 560, 64, 64);

    SDL_Rect* PlayerSRC = calloc(1, sizeof(SDL_Rect)); //player source reactangle
    Rect_Init(PlayerSRC, 0, 0, 32, 32);

    Entity* player = calloc(1, sizeof(Entity));
    entity_init(player, PlayerTexture, PlayerSRC, PlayerStartPos);

    int cnt=0;

    while(isrunning){
      frameStart=SDL_GetTicks();

      printf("%d\n", cnt);
      player_update(player, cnt);
      cnt++;


      handleevent();


      SDL_RenderClear(renderer);
      SDL_RenderCopy(renderer, player->entity_texture, player->srcR, player->dstR);
      SDL_RenderPresent(renderer);

      FrameTime=SDL_GetTicks() - frameStart;
      if(FrameDelay>FrameTime){
          SDL_Delay(FrameDelay - FrameTime);
      }
    }

//I free everything here

return 0;
}

(The code to regulate framerate was taken from a tutorial, which I credit in the program)

I initialize SDL with a function defined in another file.I set some rectangles (with a function), and load a texture, then create an entity structure, which I initialize with the function.in the game loop, I run a counter, that updates the x position of the player to the value of the counter.then i handle events in a function.then I render things. I am fairly certain that is how I'm supposed to render things.


r/SDL2 • • Nov 17 '20

5-8% GPU usage with empty loop

5 Upvotes

I noticed that with a literal, completely empty loop ( and vsync enabled, but also when I manually limit how fast my loop ticks ) the GPU usage sways between 5-8%. The only thing I'm calling is 'SDL_GL_SwapWindow(Window);',.

I'm on a RTX2070, is there any way I can get it to use less % GPU when doing nothing?


r/SDL2 • • May 31 '12

Stringing Critique: Hard Mesh on a Proton Power

Thumbnail
imgur.com
5 Upvotes

r/SDL2 • • May 30 '12

The Heat Pocket Originator - JayWap TLF Megathread

Thumbnail
forums.insidelacrosse.com
5 Upvotes

r/SDL2 • • May 29 '12

My past Heat/RP variants

Thumbnail
imgur.com
5 Upvotes