Doom monster
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > arrays in functions
 
Author
All times are GMT. The time now is 01:34. Post New Thread    Post A Reply
gggmork
If you can make any sense of this post, congratulations


Posts: 2751
Registered: 06-07


EDIT: this thread is crap
I should probably delete it in like an hour just in case someone was suckered into spending time replying to it, in case they're in the middle of typing something.



Hello and welcome to another edition of gez solves my problems.

f2 is a global array. I want to rotate f2 into f3 counter clockwise, preferably using a function so any similar array can be rotated into any other, so I can be lazy and not "redraw" f3.
code:
int f2[15][15] = { {0,0,1,2,3,4,5,6,7,7,7,7,7,7,7}, {0,0,1,2,3,4,5,6,7,7,7,7,7,7,7}, {1,1,1,2,3,4,5,6,7,7,7,7,7,7,7}, {2,2,2,2,3,4,5,6,7,7,7,7,7,7,7}, {3,3,3,3,3,4,5,6,7,7,7,7,7,7,7}, {4,4,4,4,4,4,5,6,7,7,7,7,7,7,7}, {5,5,5,5,5,5,5,6,7,7,7,7,7,7,7}, {6,6,6,6,6,6,6,6,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}}; int f3[15][15]; function int ccwRotate (int base, int target) { int bx = 0; int by = 0; int tx = 0; int ty = 14; for(by=0;by<15;by+=1) { for(bx=0;bx<15;bx+=1) { target[ty][tx] = base[by][bx]; ty-=1; } tx+=1; } }


but it says target and base aren't arrays, and yada yada yaaaaw. (don't even know if that function would work correctly because couldn't test due to errors) Tried putting base[15][15] as a parameter but it was still gheying me with ghey.

Last edited by gggmork on 01-09-13 at 10:49

Old Post 01-09-13 09:42 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
gggmork
If you can make any sense of this post, congratulations


Posts: 2751
Registered: 06-07


Oh wait, I just found this other thread by... me!!:
http://www.doomworld.com/vb/doom-ed...tion-parameter/

Old Post 01-09-13 09:57 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
gggmork
If you can make any sense of this post, congratulations


Posts: 2751
Registered: 06-07


I "solved" it, but its ugly, copy-pasted hard to reuse code/ not a function. The places where I wrote "//first rotation... //second rotation... etc" seem like a place where similar code should be wrapped into a function. But I guess you can't because arrays suck in functions.

code:
#include "zcommon.acs" int lights[8] = {96,112,128,144,160,176,192,208}; int f1[15][15] = { {6,5,4,3,2,1,0,0,0,1,2,3,4,5,6}, {7,6,5,4,3,2,1,0,1,2,3,4,5,6,7}, {7,7,6,5,4,3,2,1,2,3,4,5,6,7,7}, {7,7,7,6,5,4,3,2,3,4,5,6,7,7,7}, {7,7,7,7,6,5,4,3,4,5,6,7,7,7,7}, {7,7,7,7,7,6,5,4,5,6,7,7,7,7,7}, {7,7,7,7,7,7,6,5,6,7,7,7,7,7,7}, {7,7,7,7,7,7,7,6,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}}; int f2[15][15] = { {0,0,1,2,3,4,5,6,7,7,7,7,7,7,7}, {0,0,1,2,3,4,5,6,7,7,7,7,7,7,7}, {1,1,1,2,3,4,5,6,7,7,7,7,7,7,7}, {2,2,2,2,3,4,5,6,7,7,7,7,7,7,7}, {3,3,3,3,3,4,5,6,7,7,7,7,7,7,7}, {4,4,4,4,4,4,5,6,7,7,7,7,7,7,7}, {5,5,5,5,5,5,5,6,7,7,7,7,7,7,7}, {6,6,6,6,6,6,6,6,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}, {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}}; int f3[15][15]; int f4[15][15]; int f5[15][15]; int f6[15][15]; int f7[15][15]; int f8[15][15]; script 1 open { //first rotation into f3 int bx = 0; int by = 0; int tx = 0; int ty = 14; for(by=0;by<15;by+=1) { ty=14; for(bx=0;bx<15;bx+=1) { f3[ty][tx] = f2[by][bx]; ty-=1; } tx+=1; } //second rotation into f4 tx=0; for(by=0;by<15;by+=1) { ty=14; for(bx=0;bx<15;bx+=1) { f4[ty][tx] = f3[by][bx]; ty-=1; } tx+=1; } //third rotation into f5 tx=0; for(by=0;by<15;by+=1) { ty=14; for(bx=0;bx<15;bx+=1) { f5[ty][tx] = f4[by][bx]; ty-=1; } tx+=1; } delay(100); int y=0; for(y=0;y<15;y+=1) { print(d:f5[y][0],d:f5[y][1],d:f5[y][2],d:f5[y][3],d:f5[y][4],d:f5[y][5],d:f 5[y][6],d:f5[y][7],d:f5[y][8],d:f5[y][9],d:f5[y][10],d:f5[y][11],d:f5[y][12 ],d:f5[y][13],d:f5[y][14],s:" ",d:y); delay(35); } }

Old Post 01-09-13 10:42 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Quasar
Moderator


Posts: 6006
Registered: 08-00


Damn, dude. That's all I can really say :P

Old Post 01-09-13 17:28 #
Quasar is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
gggmork
If you can make any sense of this post, congratulations


Posts: 2751
Registered: 06-07


You can delete this topic if you want, since you're like, a "moderator".
I might find your "skank" hash useful which you mentioned in that linked topic btw. Good thing I have a memory to even remember info from past topics I made.

Old Post 01-09-13 19:15 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 01:34. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > arrays in functions

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.