Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → I have tried, but just can't get it! -cog needed
I have tried, but just can't get it! -cog needed
2003-10-04, 11:58 AM #1
like i said, i have tried writing one, but i can't get it..
i need a cog that will display random sprites at random locations(ghost)
can this be done? if so, could someone PLEASE help me out here?

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-04, 1:14 PM #2
*cracks knuckles*

Code:
# "a cog that will display random sprites at random locations(ghost)"
#
# 10/2003 gbk - gbk@insightbb.com
Symbols
Message Startup
Message Pulse
Message Timer

Thing Ghost0=-1 #If a ghost is unused, make SURE
Thing Ghost1=-1 #it is set to -1.
Thing Ghost2=-1
Thing Ghost3=-1
Thing Ghost4=-1
Thing Ghost5=-1
Thing Ghost6=-1
Thing Ghost7=-1
Thing Ghost8=-1
Thing Ghost9=-1

Template Type0 #If templates go unused, just fill the rest with the same one.
Template Type1
Template Type2
Template Type3
Template Type4
Template Type5
Template Type6
Template Type7
Template Type8
Template Type9

Flex Rate		#How often, in seconds, a new sprite is created.
Flex Halflife=1	#How long the sprite will live.  Set to -1 to disable.

Int d=-1			Local
Int r0=0			Local
Int r1=0			Local

End
Code
Startup:
Sleep(1);
Setpulse(Rate);
Stop;

Pulse:
r0 = Rand()*10;
r1 = Rand()*10;
While(r0 == 1) r0 = Rand()*10;
While(r1 == 1) r1 = Rand()*10;
While(Ghost0[r0] == -1) r0 = Rand()*10;
d = Creatething(Type0[r1], Ghost0[r0]);
If(d == -1) Print("Sprite creation failure.");
If(Halflife != -1 && d != -1) Settimerex(Halflife, 6535, d, 0);
Stop;

Timer:
If(Getthingsignature(Getparam(0)) != -1) Destroything(Getparam(0));
Stop;
End



It *should* work. I didnt test it. Didnt see the point, really.


Oh, and, do be more descriptive the next time you request a cog. I almost didnt write this one because your request is, shall we say, a bit vague.

------------------
Back in Black...
And when the moment is right, I'm gonna fly a kite.
2003-10-04, 1:28 PM #3
thnks sorry [http://forums.massassi.net/html/smile.gif]

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-04, 1:47 PM #4
hmm not working.. i set everything up correctly, but no sprites show.. i know the sprites work cuz i used them with a cog that just repeats them over and over
[http://67.87.115.203:81/brad_s/warehouse_ex.jpg]
see!
well thnks for writing it, i appreciated it, but if you could fix it, it would be sweet

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-04, 1:58 PM #5
well, i just thought of a problem.. i dont know how to fix it...
it may be that you have to list the mats that are used to animate the sprite?

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-04, 3:20 PM #6
The cog works fine for me. Check your implementation.

------------------
Back in Black...
And when the moment is right, I'm gonna fly a kite.
2003-10-06, 1:20 PM #7
I checked implementation.. it still dont work.. could it be im using animated mats for sprites?

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-06, 5:25 PM #8
Mats? Lol. No, you need real sprites - objects, things. Just mats wont do the trick.

------------------
Back in Black...
And when the moment is right, I'm gonna fly a kite.
2003-10-06, 5:39 PM #9
No, no, i know. filename.spr contains the info, you put the name of the animated mat in there. I discovered that you can only use sprites with about 14 frames or less.. bigger ones just dont work. bummer :P


------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-06, 7:05 PM #10
I thought the limit was 16 cels. [http://forums.massassi.net/html/confused.gif]


But is it working, yes?

------------------
Back in Black...
And when the moment is right, I'm gonna fly a kite.
2003-10-06, 9:16 PM #11
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Brad S:
No, no, i know. filename.spr contains the info, you put the name of the animated mat in there. I discovered that you can only use sprites with about 14 frames or less.. bigger ones just dont work. bummer :P


</font>


Say, when you added something to Template Type1, did you add a spr file there? *shaking head* In the JED's COG placement window, double click in the blank space next to the Template and select something with a + infront of it. Explotions have exp in them, so mask after "+*exp". Sparking particles have other stuff. Click around a try out stuff.
Edward's Cognative Hazards
2003-10-07, 1:50 AM #12
Listen, im pretty sure i did everything right, look:
Quote:
<font face="Verdana, Arial" size="2">
#material type width height geo light tex extralight xoff yoff zoff
explosiontest.mat 0 2.0 2.0 4 0 0 0.0 0.0 0.0 0.0

</font>


and in the master.tpl:
Quote:
<font face="Verdana, Arial" size="2">
# DESC:
# BBOX: 0 0 0 0 0 0
+explosiontest3 none orient=(0.000000/0.000000/0.000000) type=cog move=physics thingflags=0x10000000 sprite=explosiontest3.spr mass=0.050000 physflags=0x200 vel=(0.000000/0.000000/0.000000)
</font>


these sprites work with another cog, but not with this one, thats what im saying

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-07, 2:40 AM #13
Oh, sorry. When I read it once, I thought you were... noob... and thought that when you add a spr file to template, you'll get a spr file.

OK. I don't see any problems in GBK's code. So I'll make a new one:
Code:
# Create random at random.
#
# By Edward
symbols

message    startup
message    pulse

thing      ghost0
thing      ghost1
thing      ghost2
thing      ghost3
thing      ghost4
thing      ghost5
thing      ghost6
thing      ghost7
thing      ghost8
thing      ghost9
thing      ghost10
thing      ghost11
thing      ghost12
thing      ghost13
thing      ghost14
thing      ghost15

template   boom0
template   boom1
template   boom2
template   boom3
template   boom4
template   boom5
template   boom6
template   boom7
template   boom8
template   boom9
template   boom10
template   boom11
template   boom12
template   boom13
template   boom14
template   boom15
# Feel free to take away a few.
int        ghosts_in_use=15
int        booms_in_use=15

int        i              local

flex       delay_between

end
#
code
startup:
        SetPulse(delay_between);
return;
pulse:
        CreateThing(boom0[rand()*booms_in_use],ghost0[rand()*ghosts_in_use]);
return;
end

This should work. And VERY easy! If no work, then Parsec the 2 codes.

/Edward
Edward's Cognative Hazards
2003-10-07, 8:03 AM #14
I like to shy away from using 'used' variables, because n00bs never know what to put in there, so the cog ends up fudging.

------------------
Back in Black...
And when the moment is right, I'm gonna fly a kite.
2003-10-07, 4:15 PM #15
Not to sound snobby, or self praising, but im no noob, i have been editing for... 4 yrs now.. i just still have a little trouble cogging

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-10-07, 4:44 PM #16
No offense intended. I mean cog n00b. I lived and breathed cogs for years. I could think in cog at one point or another. Alot of that is gone now, but I can still code!! [http://forums.massassi.net/html/frown.gif]

------------------
Back in Black...
And when the moment is right, I'm gonna fly a kite.

↑ Up to the top!