How to compress game data in one file - c

I'm trying to make game like "Duke Nukem 3D". I will have many maps in my game and each map will have it's own (and no more!) data files such as textures, sounds and so on, that's why I need to compress all these data files to one "map" file.
So, let's image that I want to test my maps one by one, and after compiling my code I want to test my first map with her textures and sounds, And when I type in my command line something like this: ./game_name "mymap.rce" or ./game_name "mymap.zip" my game must start with map what I typed and this map must have textures and sounds which I compressed with her.
You can download demo here.
To run demo you can type this for example: ./rce demo1.rce

So, I just made my archiver(without compress). If you need it, you can find it here.

Related

Lua, Love2d, two games with the same class name in different folders

I'm new to Lua and Love2D, I did 2-3 simple games and I wanted to put them together. I did a window where you choose which game you want to play. It succeed; with a little problem. Two of my games use a ball. So both have a Ball.lua File. I use the require function to load the Ball file in each of my games. It works at first, I can play Game1, go back and play Game2 without any problem. But if I go back and want to play the Game1 again. His ball.lua File will not be required since require only load once. Then there will have an error since my game1 is trying to use my Game2's ball Class.
I wanted to know which solution would be best :
Just rename the files. (I would like to avoid it, feels hardcoding to me)
Use doFile. (I never used it, I don't even know if it would work)
Require the two Ball's Classes in my Main menu and pass it by parameter when loading each game (Don't know if it would work too)
If you want to see my code for more explanation, here's the link : https://github.com/cbelangerstpierre/Games/tree/main/Games
Thanks in advance !
As you know, require will only execute each file once. However it will also save the return value of the file so you can require the file as many times as you want and still get the same value.
In your Ball.lua files, make your Ball declarations local:
local Ball = Class{}
Then at the bottom of those files add:
return Ball
Then, change your main.lua files to store to the global Ball variable:
Ball = require "Atari-Breakout.Ball"
and
Ball = require("Switching-Ball.Ball")
Ideally, it's recommended to make all of your variables local and return tables from the files that you need to require.

Extract motion vectors from versatile video coding

How do I go about extracting motion vector into a .txt or .xml file from VVC VTM reference software. I managed to extract the motion vectors to a text file but I don't have a proper index indicating which motion vector belongs where. If anyone could guide me on getting proper index along with motion vectors, that would be very helpful.
Are you doing it at the encoder side?
If so, I suggest that you move to the decoder side and do this:
Encode the sequence from which you want to extract MVs.
Modify the decoder so it prints the MV of each coding unit, if any (e.g. not intra). To do so, you may go to CABAC Reader.cpp file, somewhere inside coding_unit() function, and find the place where MV is parsed. There, in addition to the parsed MV, you have access to coordinates of the ongoing CU.
Decode your encoded bitstream with the modified VTM decoder and print what you wanted to be printed.
As Mosen's answer, I recommend you to extract any information(include MVs) from the decoder.
If you just want to extract MVs to file, you may utilize traverseCU().
VTM's picture class has CodingStructure class which traverses all CUs in picture(even CTU or CU can be treated as CodingStructure class, so you can use traverseCU() at block level too).
So I suggest you to
Access picture class(its name might be different, e.g., m_pcPic at DecLib.cpp) at the decoder side(insert you code before/after execute loop filters).
Iterate each CUs in picutre by using traverseCU().
Extract MVs from every CU you accessed, and save those information(MVs, indices, etc.)
Although there might be better ways to answer your question, i hope this answer helps you.

Is it possible to convert a image to an Array?

I want to be able to input an image and get out an Array such as {{55,132,97},{55,125,97},} for an image, 1 Array per pixel
what I need help with is how would I go about this? I would prefer lua but I could also use C# and python
also what libraries or whatever they are called would I need?

Simple Multi-Blob Detection of a Binary Image?

If there is a given 2d array of an image, where threshold has been done and now is in binary information.
Is there any particular way to process this image to that I get multiple blob's coordinates on the image?
I can't use openCV because this process needs to run simultaneously on 10+ simulated robots on a custom simulator in C.
I need the blobs xy coordinates, but first I need to find those multiple blobs first.
Simplest criteria of pixel group size should be enough. But I don't have any clue how to start the coding.
PS: Single blob should be no problem. Problem is multiple blobs.
Just a head start ?
Have a look at QuickBlob which is a small, standalone C library that sounds perfectly suited for your needs.
QuickBlob comes with a small command-line tool (csv-blobs) that outputs the position and size of each blob found within the input image:
./csv-blobs white image.png
X,Y,size,color
28.37,10.90,41,white
51.64,10.36,42,white
...
Here's an example (output image is produced thanks to the show-blobs.py tiny Python utility that comes with QuickBlob):
You can go through the binary image labeling the connected parts with an algorithm like the following:
Create a 2D array of ints, labelArray, that will hold the labels of the connected regions and initiate it to all zeros.
Iterate over each binary pixel, p, row by row
A. If p is true and the corresponding value for this position in the labelArray is 0 (unlabeled), assign it to a new label and do a breadth-first search that will add all surrounding binary pixels that are also true to that same label.
The only issue now is if you have multiple blobs that are touching each other. Because you know the size of the blobs, you should be able to figure out how many blobs are in a given connected region. This is the tricky part. You can try doing a k-means clustering at this point. You can also try other methods like using binary dilation.
I know that I am very late to the party, but I am just adding this for the benefipeople who are researching this problem.
Here is a nice description that might fit your needs.
http://www.mcs.csueastbay.edu/~grewe/CS6825/Mat/BinaryImageProcessing/BlobDetection.htm

Cut a jpg file in C, (NOT crop)

i would like to know how can i cut a jpg file using a coordinates i want to retrieve using artoolkit and opencv, see:
Blob Detection
i want to retrieve coordinates of the white sheet and then use those coordinates to cut a jpg file I'm took before.
Find this but how can this help?
How to slice/cut an image into pieces
If you already have the coordinates, you might want to deskew the image first:
http://nuigroup.com/?ACT=28&fid=27&aid=1892_H6eNAaign4Mrnn30Au8d
This post uses cv::warpPerspective() to achieve that effect.
The references above use the C++ interface of OpenCV, but I'm sure you are capable of converting between the two.
Second, cutting a particular area of an image is known as extracting a Region Of Interest (ROI). The general procedure is: create a CvRect to define your ROI and then call cvSetImageROI() followed by cvSaveImage() to save it on the disk.
This post shares C code to achieve this task.

Resources