Questions tagged [c]

C is a general-purpose computer programming language used for operating systems, libraries, games and other high performance work.

Filter by
Sorted by
Tagged with
0
votes
1answer
61 views

while(1) in separate threads. safe and efficient

In my TCP multithreaded server written in C, I have multiple threads with infinite loops checking for new inputs from thread safe queue and then doing their jobs. pseudocode: ...
2
votes
0answers
35 views

What is wrong with my collision resolution function?

I have been able to implement the following linear collision resolution function, based on these tutorials, for a given pair of in-game objects that gives good results: ...
1
vote
0answers
33 views

How would I implement a level transition when reaching a cave in Raylib?

I am the developer of an upcoming 2d/3dRPG. I have a simple scene setup where there is a bridge over some acid and a cave entrance-like thing that I want to change the level with. I have used C and C++...
0
votes
0answers
21 views

How to implement Core War's .X modifier

I'm trying to write an implementation of Core War for an exercise. I'm stuck with the implementation of the X modifier. This is the definition (all quotes from https://corewar.co.uk/standards/icws94....
0
votes
0answers
32 views

SDL 2 SDL_BLENDMODE_BLEND way faster. Why?

I was just tinkering around with a simple ecs, when I noticed drawing like 20,000 rectangles killed my framerate (~10 FPS). I thought ok, maybe it's just too many. Later I wanted to draw them ...
0
votes
0answers
52 views

State machine in C for SDL game

I want to create a state machine for menu in my SDL game. So this is my code without the SDL I just want to ask if this is a good way to create it. here is a code: ...
0
votes
1answer
92 views

Need help with optimizing loops scanning for enemies in tile based horizontal scroller

I'm looking for an optimization for my loops searching for enemies in a tile based horizonal scroller. My enemy array is in a struct and I am looping through the array with 3 loops. First loop finds ...
1
vote
2answers
108 views

Why would I want to set a minimal OpenGL version before creating the context?

Typical GLFW applications have these lines after glfwInit(): ...
0
votes
0answers
42 views

Best way to save screenshots in a game?

I'm making a game, and I'm adding a screenshots feature. Currently I save screenshot files to <Home Directory>/Pictures/MyGame/. However, I'm not sure if ...
0
votes
1answer
92 views

Are there any serious advantages for C++ compared to C? [closed]

so I know a little bit about C (read like a few university level textbooks on it, I am not an experienced programmer or anything) and now I would like to learn the ropes of the Unreal engine to fidle ...
-1
votes
2answers
101 views

How can I handle input in C without halting the main loop?

I want my C program to update the console every second, and it was working fine until I tried to handle input. Now the program halts since it waits an input from the user. How can I do this? ...
0
votes
0answers
48 views

Problem with bullet movement

I'm trying to draw "bullets" in my game, but I think something is wrong with velocity computation. Sometimes the "bullets" are going in the right way, but sometimes they won't. The ...
1
vote
0answers
99 views

glReadPixels performance not improving with PBO

I'm currently using glReadPixels to read from the depth buffer to calculate where on the map the player is pointing, for the purpose of placing objects on the ground. I do this after rendering the ...
0
votes
0answers
22 views

Binding the camera to the body of the skeleton

It is necessary to design: "Only the body of the skeleton rotates with the camera" Problem above I'm not advanced. My hunch: Programming CapsuleComponent.h - inherit skeleton components. I ...
0
votes
0answers
126 views

How to load a PNG in pure C

PNG loading: I've been creating a game engine for almost a year, and since the start of the development, I have been using stb_image for loading images. It ...
0
votes
2answers
309 views

Rotating camera in 3D without yawing diagonally

I'm programming a C raytracer. I'm having trouble getting the camera to rotate the way I intend. I would like the camera to rotate by pressing keys: F & H rotate left & right around the world'...
1
vote
1answer
344 views

How can I render a font in C with OpenGL?

What I tried: I was testing some things in order to render text with stb_truetype.h and OpenGL in C. I took as a reference the example that appears here. Basically, this example, loads a .ttf file and ...
2
votes
1answer
85 views

Polling events with SDL results in stuttering response when dealing with multiple objects

I'm new to SDL programming and I'm not quite sure I got how it handles events. Given an instance like this defined in "game.c": ...
2
votes
1answer
144 views

Rotate Object in world space - Raytracing

I’m programming a C raytracing project. I’ve been wanting to implement object rotations (square, cylinder) for several days but I can’t do it. For each object I have its position (x, y, z) in the ...
6
votes
3answers
2k views

Convert integer to float while also dividing down the scale, without data loss

I'm working on a game, and my intent is to avoid use of floating point for unit positions. To that end, I'm using 32-bit integers for all positions, with a millimeter scale. However, for rendering, I ...
2
votes
1answer
69 views

Reducing adjacency bookkeeping work in constrained Delaunay triangulation

I'm using the Sloan algorithm for constraining a generated Delaunay triangulation. This primarily consists of edge flipping for the edges that overlap the constrained edges. In order to flip an edge, ...
1
vote
0answers
48 views

Understanding Quake I Timer

Here is a snippet of code from Quake I. ...
0
votes
0answers
47 views

I need help with my pathfinding algorithm

I am a student that is learning how to program and I started to develop my first platform game using C. However, I’m struggling with the pathfinding algorithm for the enemies. My levels are basically ...
0
votes
1answer
496 views

SDL2. Why I'm getting a Segmentation Fault in the free() function? Also, am I doing the rendering stuff right?

So, I'm new at C programming and SDL2 and I'm trying to get something working here to write some games. First, I would like to know if I'm doing the rendering stuff the right way. I'm kind of ...
0
votes
0answers
341 views

Creating a game on Linux with SDL and distributing it

TL, DR: Will I be able to get a single .exe file which will work smooth in a PC which does not have SDL or so installed ever. If not, how close will be the closest ...
1
vote
1answer
76 views

Throttling or adding delays between OnTriggerEnter2D calls

I have 2 game objects: Explosion and Enemy. At any given point, an enemy can collide with multiple ...
0
votes
0answers
141 views

Cyclone LED gaming code HOW TO HELP?

I am very new to programming. For a project I decided to make a game of cyclone using some LEDs,a push button, and a raspberry pi. I researched how to at least start on the game, but the problem that ...
0
votes
1answer
283 views

Proper 2D isometric tile depth sorting?

I'm using Raylib, and I'm attempting to place tiles on a level, and the algorithm for placing the tiles is working. The problem is that the player will display over the walls on the bottom right hand ...
3
votes
2answers
79 views

Need to programatically muffle game sounds

So I work on a multiplayer game that is set in space. There are essentially two environments for players to be in: inside a sealed space station (where there is air and thus sounds) and outside the ...
1
vote
0answers
128 views

Implementation of continous, grid aligned, smooth movement (C / C++)

I've been trying to make my own implementation of Snake clone using Allegro 5 / C. Unfortunetaly I can't find a good method to align x & y position of snake to grid. I'm looking for some good ...
0
votes
1answer
118 views

ANSI C Video Game Item System

I am looking to program my own little Role Playing Game using... ANSI C or "standard C", (NOT C++) as my programming language The SDL2 development library I have got a very basic and simple type of ...
2
votes
1answer
923 views

What do I provide to SDL_LockTexture **pixels?

All I'm trying to do is write random data to an array, then display that array to a window. But I can't get SDL_LockTexture to cooperate, it keeps complaining that I'm using the wrong argument. I've ...
1
vote
2answers
705 views

How should I store loaded world chunks in RAM (For my game similar to Minecraft)?

I am trying to replicate a chunk loading system, in C, for my own minecraft like game, though I don't know how. Once chunks are loaded, are they placed in an array, or are there a bunch of variables ...
-2
votes
1answer
89 views

What are the ascii numbers for shift and control? [closed]

I is trying to makey makey a program that will detect when certain keys are pushed. My only problem is that I dont know the nombers that corrospond to the shift key and control keys. I am writing this ...
0
votes
2answers
131 views

Quaternion rotation around center, undefined behavior

Here's my code: ...
3
votes
1answer
6k views

How could I implement an ECS in C? [closed]

I'm looking into how to do a game engine using only C and wanted to know how to implement ECS in C. I didn't find any ECS implementation for C, it only seems to exist for C++. So I'm wondering... Is ...
1
vote
1answer
72 views
1
vote
0answers
36 views

what do you choose to point player in multiplayer game coding?

I'm making C or C++ texture multiplayer game (monopoly) and to code multiplayer, defined type user when you change player or point player in main() or other() you choose Number or pointer? for ...
2
votes
2answers
378 views

How to save game state in C in Allegro?

I'm developing my 1st board-game (go-game) in C with Allegro 5, for a course project. Part of my goal is to make a gamesave of the current gamestate. Let's say for 2 players if we exit the game, and ...
1
vote
2answers
141 views

Getting Model View Matrix by hand

Right now I'm trying to calculate the model view matrix by hand... The App is 2D. I have something like this: ...
0
votes
1answer
209 views

Wrong angles given by atan2

I have a method to calculate angle between two vectors, but it is giving wrong values. here is the code : ...
0
votes
0answers
63 views

How can I make this tile map correctly?

I'm having the following problem creating this hexa tiled map. this is what I wanted : [EDIT] Ok I've Managed to do this: ...
1
vote
0answers
186 views

Doom-style 8 directions sprite math HELP C++ [duplicate]

I'm trying to get Doom-style 8 direction sprite rotation that changes its sprite depending on the camera and the forward vector of the entity just like this video here: https://www.youtube.com/watch?v=...
1
vote
1answer
39 views

Trying to translate object

I'm trying to tranlate a matrix by xy but the result is strange. can someone help me translate and rotate the matrix properly? ...
1
vote
2answers
214 views

Is it possible to make desktop visible behind drawn object using SDL2?

I would like to draw an avatar over the desktop, something similar to those word 97 assistants, my idea so far is to make only the background transparent but I haven't had any luck, any suggestion? is ...
2
votes
1answer
2k views

How do I check if a window has focus in SDL2?

Is there a replacement for SDL_GetAppState function in SDL2 from older SDL versions? Why was it removed? I want to use it so I can check if the user has focused the ...
0
votes
2answers
255 views

SDL2 only renders a single image

As an attempt to learn SDL on C, I decided to try and create a simple Pong program using it. My problem now is that of the textures I've given it, two paddles and a ball, only the ball is rendered. It ...
4
votes
0answers
87 views

Is the C or the Android code a problem?

Starting to write a game, it'll have a C server, and at the very least an Android client. However I have run into an issue where I can't seem to get them to connect. I have thrown debug logging into ...
2
votes
1answer
9k views

Why am I getting these errors when including stb_image.h? [closed]

I'm trying to put an include guard around including stb_image.h (from the well-known public domain image library). I have noticed that, unusually, the include ...
1
vote
1answer
75 views

Segmentation Fault using Allegro_Tiled, function al_open_map();

I have consistently segfaulted trying to load a TMX file into a *map. ...

1
2 3 4 5 6