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
1 answer
29 views

glDrawArrays draws nothing in C. Trying to draw point in openGL(in C), no error but draws nothing

...
user avatar
  • 1
2 votes
1 answer
271 views

SDL2 memory leak

I've been creating a 2D game in sdl2 in C and within my main game loop, I have found a section of code that causes a massive memory leak in my program, roughly leaking 100MB of memory per second. The ...
user avatar
0 votes
1 answer
664 views

How to create editable SDL2 text input boxes?

Hi all, I'm working on an SDL2 project and I require multiple editable square textboxes as shown in the image above. Is there any way I can do this?
user avatar
0 votes
1 answer
37 views

Rotation matrix for a model where the forward axis is not +X

I'm trying to convert a normalized unit vector, representing an entity heading, into a rotation matrix for rendering. The problem is that I'm using an (apparently) unusual forward vector for my ...
user avatar
  • 762
0 votes
0 answers
10 views

Is there a way to wait before drawing a bitmap in Allegro5?

I'm have two characters, one is playable and the second is not. A keyboard event changes the variable that draws the idle/attack bitmaps of the playable character. Is there a way to wait before the ...
user avatar
1 vote
1 answer
80 views

Can't create Render Target with CreateDxgiSurfaceRenderTarget

I'm trying to create ID2D1RenderTarget to be used for writing text with DirectWrite. I tried two methods but can't get it working, both yield "The parameter is incorrect" error code. In the ...
user avatar
1 vote
1 answer
87 views

One global game loop vs multiple local game loops

What are the advantages of using multiple game loops instead of one? Assume Level1, Level2, Level3. These levels may bring totally different problems and needs and they may also be completely separate,...
user avatar
0 votes
1 answer
84 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: ...
user avatar
1 vote
0 answers
50 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: ...
user avatar
0 votes
0 answers
52 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++...
user avatar
0 votes
0 answers
121 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: ...
user avatar
0 votes
1 answer
104 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 ...
user avatar
1 vote
2 answers
196 views

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

Typical GLFW applications have these lines after glfwInit(): ...
user avatar
0 votes
0 answers
51 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 ...
user avatar
0 votes
1 answer
109 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 ...
user avatar
  • 101
0 votes
2 answers
127 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? ...
user avatar
  • 35
0 votes
0 answers
58 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 ...
user avatar
1 vote
0 answers
182 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 ...
user avatar
  • 762
0 votes
0 answers
431 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 ...
user avatar
0 votes
2 answers
539 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'...
user avatar
  • 21
1 vote
1 answer
687 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 ...
user avatar
1 vote
1 answer
182 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": ...
user avatar
  • 113
2 votes
1 answer
217 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 ...
user avatar
  • 21
6 votes
3 answers
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 ...
user avatar
  • 762
2 votes
2 answers
75 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, ...
user avatar
  • 762
1 vote
0 answers
66 views

Understanding Quake I Timer

Here is a snippet of code from Quake I. ...
user avatar
0 votes
0 answers
53 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 ...
user avatar
0 votes
1 answer
957 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 ...
user avatar
0 votes
1 answer
626 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 ...
user avatar
  • 101
1 vote
1 answer
91 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 ...
user avatar
  • 121
0 votes
0 answers
154 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 ...
user avatar
0 votes
1 answer
407 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 ...
user avatar
3 votes
2 answers
86 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 ...
user avatar
  • 31
1 vote
0 answers
177 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 ...
user avatar
  • 57
0 votes
1 answer
146 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 ...
user avatar
2 votes
1 answer
2k 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 ...
user avatar
  • 183
1 vote
2 answers
840 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 ...
user avatar
-2 votes
1 answer
97 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 ...
user avatar
0 votes
2 answers
316 views

Quaternion rotation around center, undefined behavior

Here's my code: ...
user avatar
3 votes
1 answer
9k 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 ...
user avatar
  • 33
1 vote
1 answer
78 views

Why do I get these weird errors when using pow() for my game?

...
user avatar
1 vote
0 answers
38 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 ...
user avatar
3 votes
2 answers
438 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 ...
user avatar
  • 31
1 vote
2 answers
174 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: ...
user avatar
0 votes
1 answer
280 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 : ...
user avatar
0 votes
0 answers
65 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: ...
user avatar
1 vote
0 answers
214 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=...
user avatar
1 vote
1 answer
41 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? ...
user avatar
1 vote
2 answers
256 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 ...
user avatar
  • 11
3 votes
1 answer
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 ...
user avatar
  • 529

1
2 3 4 5 6