More c halp

More c halp

SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
Ok so lets say I have a text file that reads
code
@^@.((j-@-0^^{@a.^{0
^0^@.--o@j^@^{{-@{{^
^-...-^..@.@.@{[{{@.
--..@a^...@.--]-u--@
-.@a.^.@.^a--{{..y--
a..@^^@.^@.@{{^@([(@
.@.^0--@^..@]-...-u^
@(.^^.-...@{{--0@-.^
@(....a.@(({.a@..@^@
--a@..@((,,,(^@..a^^
.@-.@(,,,,%,,(^^..@^
.^--(,,%,,,,,(a--..@
^@@-(,,,,,,,,,,.-@..
^--a,%,,,,,%,,,(p..^
--@(,,,,,,,,,,,,(.0@
t..,,,,,%,,,,,%,,(-p
@0(,%,,,,,,,,,,,,,--
(@(,,,,,,,%,,,,,%,(@
,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,


I want it to rotate 90 degrees to the right and then the whole thing gets inverted, I know how to invert it, but rotating it seems a bit hard so please help
Free Steam Games
 
 
2012 Jan 25 at 15:51 PST
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
I was going to screenshot this thread and rotate it then post the image, but that's more work than telling you to read the file into an array then index the bits you need and put that into a second array (because it is not an in-place transform).
code

[0] [1] [2] In this setup, the numbers are the indexing
[3] [4] [5] variables for the array. Zero moves to two,
[6] [7] [8] etc. There will be some formula governing the
transform but you can work that out :)
 
 
2012 Jan 25 at 17:17 PST — Ed. 2012 Jan 25 at 17:18 PST
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
Well you see, the file isn't a small square, but is quite large, and honestly I have no idea how to figure it out, and I hoped there would be some function that someone made that rotates arrays, but apparently not...
Free Steam Games
 
 
2012 Jan 25 at 17:30 PST
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
and also it's not a square, but a rectangle
Free Steam Games
 
 
2012 Jan 25 at 17:32 PST
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
No thanks to dr's help, I fixed it
code
for(n=0;n<b;n++)
{
for(m=0;m<h;m++)
{
fprintf(savefile,"%s",map[n][m]);
}
fprintf(savefile,"\n");
}


I had to put the breathe of the map file before the height, soooo yeah
Free Steam Games
 
 
2012 Jan 25 at 17:53 PST
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
And fyi here's the whole thing, that finally works, and it's for this online game
awbw.amarriner.com
code
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE * thefile;
FILE * savefile;
thefile = fopen(argv[1],"r");
savefile = fopen(argv[2],"w");
if(thefile!=NULL)
{
printf("%s has been successfully opened\nWriting to %s\n",argv[1],argv[2]);
}
else
{
printf("%s failed to open... exiting",argv[1]);
exit(1);
}
int i,o,k,h,b;
int p = 0;
char *t_name[52];
int t_loc[52];
t_name[0] = ".";
t_loc[0] = 0;
t_name[1] = "%";
t_loc[1] = 30;
t_name[2] = ",";
t_loc[2] = 60;
t_name[3] = "@";
t_loc[3] = 90;
t_name[4] = "0"; //0 = black tile = error
t_loc[4] = 120;
t_name[5] = "^";
t_loc[5] = 150;
t_name[6] = "0";
t_loc[6] = 180;
t_name[7] = "^";
t_loc[7] = 210;
t_name[8] = "-";//aws doesn't save road data, it fixes road on program
t_loc[8] = 1;
t_name[9] = "[";
t_loc[9] = 2;
t_name[10] = "]";
t_loc[10] = 32;
//t_name[11] = "-";//aws doesn't save road data, it fixes road on program
//t_loc[11] = 1;
t_name[12] = "{";//aws also doesn't save river data
t_loc[12] = 3;
t_name[13] = ",";//aws doesn't save data on sea
t_loc[13] = 60;
t_name[14] = "(";//aws doesnt save data on shoals
t_loc[14] = 39;
// t_name[15] = "-";
//t_loc[15] = 1;
// t_name[16] = "@";
// t_loc[16] = 90;
// t_name[17] = "@";
// t_loc[17] = 90;
t_name[18] = "0";//awbw upload function doesn't have data for pipes
t_loc[18] = 16;
t_name[19] = "0";
t_loc[19] = 226;
t_name[20] = "0";
t_loc[20] = 167;
// t_name[21] = "0";
// t_loc[21] = 167;//aws doesn't save data on damaged pipe type
t_name[22] = "i";
t_loc[22] = 44;
t_name[23] = "e";
t_loc[23] = 45;
t_name[24] = "f";
t_loc[24] = 46;
t_name[25] = "g";
t_loc[25] = 47;
t_name[26] = "h";
t_loc[26] = 48;
t_name[27] = "o";
t_loc[27] = 54;
t_name[28] = "j";
t_loc[28] = 55;
t_name[29] = "l";
t_loc[29] = 56;
t_name[30] = "m";
t_loc[30] = 57;
t_name[31] = "n";
t_loc[31] = 58;
t_name[32] = "t";
t_loc[32] = 64;
t_name[33] = "p";
t_loc[33] = 65;
t_name[34] = "q";
t_loc[34] = 66;
t_name[35] = "r";
t_loc[35] = 67;
t_name[36] = "s";
t_loc[36] = 68;
t_name[37] = "y";
t_loc[37] = 74;
t_name[38] = "u";
t_loc[38] = 75;
t_name[39] = "v";
t_loc[39] = 76;
t_name[40] = "w";
t_loc[40] = 77;
t_name[41] = "x";
t_loc[41] = 78;
t_name[42] = "5";
t_loc[42] = 84;
t_name[43] = "1";
t_loc[43] = 85;
t_name[44] = "2";
t_loc[44] = 86;
t_name[45] = "3";
t_loc[45] = 87;
t_name[46] = "4";
t_loc[46] = 88;
t_name[47] = "a";
t_loc[47] = 95;
t_name[48] = "b";
t_loc[48] = 96;
t_name[49] = "c";
t_loc[49] = 97;
t_name[50] = "d";
t_loc[50] = 98;
for(i=0; i<10; i++)
{
o = fgetc(thefile); //unimportant
}
o = fgetc(thefile);
h = o; // h = height
o = fgetc(thefile);
b = o; // b = base
o = fgetc(thefile); //tileset - not needed
int l=0,j=0;
char *map[h+b][b+h];
for(i=0; i<((h*b)*2); i++)
{
//printf("%d",fgetc(thefile));
if ((i & 1) == 0)
{
o = fgetc(thefile); //IMPORTANT!! after each byte there is an zero!
if((p%b)==0&&i!=0)
{
// printf("\n");
//fprintf(savefile,"\n");
l++;
j=0;
}
for(k=0; k<52; k++)
{
if(o==t_loc[k])
{
// printf("%s",t_name[k]);
// fprintf(savefile,"%s",t_name[k]);
map[j][l] = t_name[k];
// printf("%s",map[j][l]); //works
j++;
break;
}
else if(k==51)
{
//printf("0");
map[j][l] = "0";
// printf("%s",map[j][l]);
//fprintf(savefile,"0");
j++;
break;
}
}
}
else
{
o = fgetc(thefile); //skip odd
p++;
}
}
printf("\n");
int n,m;
for(n=0;n<b;n++)
{
for(m=0;m<h;m++)
{
fprintf(savefile,"%s",map[n][m]);
}
if(n!=(b-1))
{
fprintf(savefile,"\n");
}
}
return 0;
}
Free Steam Games
 
 
2012 Jan 25 at 18:13 PST
Down Rodeo
Cap'n Moth of the Firehouse

Find the Hole II Participation Medal
2007 Oct 19 • 5486
57,583 ₧
Happy to help. I should have realised there's an easy way to do it with altering the order of the indices.
 
 
2012 Jan 26 at 02:58 PST
SuperJer
Websiteman

2005 Mar 20 • 6299
Don't be afraid to use aggregate initialization.

c code
int t_loc[52] = {
0, 30, 60, 90, 120, 150, 180, 210, 1, 2,
32, 1, 3, 60, 39, 1, 90, 90, 16, 226,
167, 167, 44, 45, 46, 47, 48, 54, 55, 56,
57, 58, 64, 65, 66, 67, 68, 74, 75, 76,
77, 78, 84, 85, 86, 87, 88, 95, 96, 97,
98
};

char *t_name[52] = {
".", "%", ",", "@", "0", "^", "0", "^", "-", "[",
"]", "-", "{", ",", "(", "-", "@", "@", "0", "0",
"0", "0", "i", "e", "f", "g", "h", "o", "j", "l",
"m", "n", "t", "p", "q", "r", "s", "y", "u", "v",
"w", "x", "5", "1", "2", "3", "4", "a", "b", "c",
"d"
};
 
 
2012 Jan 28 at 21:50 PST
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 13 • 2045
So.... SRAW works for Nintendo?
 
 
2012 Feb 13 at 18:48 PST
SRAW
Rocket Man

2007 Nov 6 • 2525
601 ₧
lol no, and seeing how my problem was like more complicated than yours, you shouldn't had to come crying for help here... it's not like I did
Free Steam Games
 
 
2012 Feb 13 at 18:56 PST
Page [1]