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
-1
votes
0answers
35 views

How to have a 2d array with a different number of elements in each row, and the number of rows is determined at runtime? [on hold]

How to have a 2d array with a different number of elements in each row, and the number of rows is determined at runtime? This question was asked and is similar to mine. The only difference is what if ...
0
votes
1answer
161 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 ...
-1
votes
1answer
52 views

What are the ascii numbers for shift and control?

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
0answers
21 views

Quaternion rotation around center, undefined behavior

Here's my code: ...
0
votes
1answer
154 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 ...
0
votes
0answers
20 views

How to handle mouse to look around (Win API)?

I've made a command prompt game engine. It handles input using Windows Messages, but now I came up with idea of adding mouse input. Currently I wrote a 3D maze game and I'd like to make mouse look ...
0
votes
0answers
51 views

Is there a way to numerically determine the ranking of poker hands? [duplicate]

I'm having to create a poker game called "Jacks or Better" as part of an assignment. As with all poker games, there are various combinations of 5 cards that have different ranking. So my question is: ...
1
vote
1answer
55 views
1
vote
0answers
30 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 ...
0
votes
1answer
131 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 ...
0
votes
0answers
27 views

how to register update function in Lua from C game engine?

This is my first attempt to make a SDL2 based 2d game engine in C, i am planning using Lua as scripting language for gameplay purposes. First i learned how to call a C function from Lua: ...
1
vote
2answers
79 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 Somethign like this.. ...
0
votes
1answer
112 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
56 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
72 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=...
0
votes
1answer
47 views

OpenGL Tiled map texturing problem

Some Tiles in my map are drawn wrong, I think it might be a indexing problem. Here's the output : some tiles just look wrong!! I'm not sure where i'm going wrong with my code, so please take a look. ...
1
vote
1answer
31 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
115 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 ...
1
vote
1answer
530 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
88 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 ...
3
votes
0answers
53 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 ...
1
vote
0answers
173 views

ANSI C (C11) math libraries? [closed]

I know there are a multitude of C++ math libraries out there, but my current project is C-only (C11). So far I've made due with writing my own matrix/vector functions, but now I need to do the more ...
0
votes
1answer
2k views

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

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
50 views

Segmentation Fault using Allegro_Tiled, function al_open_map();

I have consistently segfaulted trying to load a TMX file into a *map. ...
1
vote
1answer
2k views

Are there any game engines for developing in C? [closed]

I cant find any game engines which use C, mostly just Java, Anyone know any good engines that support 2d Development in C? ALso I have an additional question how hard is it to write your own game ...
1
vote
1answer
126 views

Change the image of sdl window with a new one

I will make a game and it has 3 buttons on its menu. Those buttons supposed to change the picture the background of the menu When i click on play, another picture should appear like so I found a ...
0
votes
1answer
387 views

Programming Action RPG Battle system

My best goal atm is just make one 1vs1 battle with no animations more than something which makes me realize the attack is done. I'm learning C and Xlib, and now I know how to put an image in a window ...
2
votes
1answer
239 views

How to handle Japanese on Windows and Linux using SDL_ttf and C++?

In SDL_ttf, there are a few functions provided that handles non-ASCII string literals, such as: TTF_RenderUNICODE_Solid ...
-2
votes
1answer
311 views

Find a vector 90 degrees to the right of a given angle

Can you help transform this function to move the point not only by Forward distance but also by a distance to the right or left? ...
2
votes
1answer
1k views

Handling variable frame rate in SDL2

i am creating a game with C++ and SDL2 game engine but i noticed this. I used the Vsync option for rendering, so it'll render at 60fps. If i use this game with another monitor, fps are different (for ...
2
votes
2answers
172 views

Mixing DirectX headers with C mod project not working

I'm trying to add a DirectX 11 renderer (not sure if that is even doable in a "simple" manner) to the Return To Castle Wolfenstein source code and I'm having some problems. I have a rendering class in ...
1
vote
0answers
152 views

How do I detect collision between an ellipse and a rhombus?

I'm building a game in C/C++ (been alternating between the two), but one of the biggest problems I've run into is collision detection. The game is isometric and exists on a 2x1 grid (e.g. the base ...
1
vote
1answer
396 views

SDL 2.0 OpenGL not drawing anything except background

My 'hello triangle' compiles well, no errors, but doesn't drawing anything. Here's my code: main.cpp ...
1
vote
0answers
68 views

2D Collisions engine

I am working on a fabric simulator at low level, I have done some work and at this point there are some points where I would appreciate help. The input of the program is a DRF file. This is a format ...
2
votes
2answers
491 views

Setting a uniform float in a fragment shader results in strange values, is this a type conversion? How can it be fixed?

First, some details: I'm learning OpenGL from the tutorials on https://open.gl My computer is running Linux Mint 18.1 Xfce 64-bit My graphics card is a GeForce GTX 960M OpenGL Version: 4.5.0 NVIDIA ...
1
vote
0answers
116 views

Linux: blit image on screen without stuttering at a stable frame rate

I'm working on a very simple game, and one of the project goals is to minimise the use of libraries. I'm drawing every frame into a buffer, which is then displayed using ...
0
votes
6answers
209 views

C/C++ Flexible yet fast way of linking UI elements to functions

I am currently working on the UI functionality of my game, which will have very minimal GUI design, yet it needs to be functional and flexible e.g. easy to redesign. I am planning to construct all my ...
1
vote
2answers
178 views

Network game like MMO - TPC or UDP [closed]

I saw this subject several times, however I will wish better understand. I am working on the development of a 2d game like a little MMO. (Currently I only do research). I see people who says it's ...
3
votes
1answer
3k views

Key released, multiple Keys, how to go around ncurses limitations?

I have been trying to make a small game in the terminal in C++ using ncurses. After searching around for some time, I came to realize that ncurses is pretty limiting as far as keyboard inputs are ...
0
votes
1answer
180 views

glUniformMatrix4dv with a unidimensional array

I am trying to convert this C++ gml code to C and am getting the same array but I cannot see anything on the screen, is there something I am doing wrong maybe on the shader? GML code in C++: ...
0
votes
1answer
55 views

How to move from A to B, with check and fix the destiny?

I only found the formula for check the collision between two lines. But never about of movement and fixed from one point to other point in one of the line. I need move from pA to pB and if take ...
-1
votes
1answer
1k views

Rotate Earth around sun, and moon around earth

SOLVED: I'm trying to rotate the moon around the earth. Which this part of the code only the earth is rotated around the sun, how can I make the axis to be center of earth's object? I thought about ...
1
vote
1answer
623 views

SDL_RenderPresent is writing over the previous frame

Whenever I call SDL_RenderPresent, the previous frame is replaced with black before the new frame is displayed. It's almost like when I call ...
5
votes
1answer
1k views

Drawing at floating point position

The library I am using (SDL2) only supports drawing to int positions. I am currently storing my objects positions as double, and ...
-1
votes
1answer
52 views

Why do I get this compiler error when trying to include Allegro headers on a Mac?

I ran brew install allegro on OSX while following this tutorial. My code looks like this: ...
0
votes
1answer
83 views

Can't figure out how to create texture from a font-surface

I can't seem to be able to render my font, it crashes and I can't figure out why. It seems to load the font correctly, but the parts relating to surface crashes. Why does my texture crash? Here is ...
1
vote
1answer
145 views

How do I use data-orientated programming without object-orientated programming?

I have been reading many resources about data oriented programming, and one thing I understand about it is that it's about keeping chunks of memory together to improve performance. Other than that, I ...
1
vote
1answer
133 views

SDL Player do something for 3 seconds then stop

I'll make my player respawn after 1 of his lives is taken, but I want him to be invincible for 2 or 3 seconds and not instadie again because he will be in the way of enemy bullets. ...
1
vote
1answer
111 views

SDL Detect change score

I have this in my loop , it works but I get verry low fps and game is working in slow motion : ...
0
votes
1answer
611 views

C SDL render text?

I'm making a game in C using SDL library and I want to display a score. I have 9 photos with numbers from 0-9 and I want to know if I can use them somehow to display score, if my score is 2679 the ...