4 registered members (Quad, TipmyPip, Nymphodora, 1 invisible),
336
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
2D Shadows
#372689
06/03/11 16:07
06/03/11 16:07
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
Hey guys. ^-^ I'm programming a little 2D-RPG and want my 2D-objects to throw a shadow. This shadow should be rotatable and dilatable, so I need the position of every pixel. I think, the best way for that is to save the shadow-information into structs and every pixel-position into an array of it, but the shadows have different sizes, so the arrays would not have the same lenghts. Well, I could define giant arrays which could save every size of shadow, but there are many shadows, so there would be thousands of not used variables. Also Bitmaps are very slow to read pixels out, so changing the lenght of the array would be the smartest way, but the manual says, I can't change them at runtime, so is there a way, to define every struct with an other array-lenght? Or do you have an other idea how to solve that? Some tips would be very nice. :3 ~greets
Hilf mir, dir zu helfen!
|
|
|
Re: 2D Shadows
[Re: TheShooter]
#372705
06/03/11 18:23
06/03/11 18:23
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
No no, rotating and expansion is really not the problem, I want to save the several pixel-positions of the shadow in an array so I can write my own functions for expansion and rotating (I have my reasons doing that), so I need dynamic arrays for different shadow-sizes.
Hilf mir, dir zu helfen!
|
|
|
Re: 2D Shadows
[Re: Slin]
#372713
06/03/11 19:35
06/03/11 19:35
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
I want the shadow to overlap other objects (with the same layer as the own one), but not the own one itself, and for rotating and expanding I have to calculate every pixel, so I think it's easier to have all pixelpositions saved in an array.
You can dynamically allocate memory using sys_malloc.
That's the part I need. ^-^ I just don't know how to code that for arrays. I think a little example should do the job.
Hilf mir, dir zu helfen!
|
|
|
Re: 2D Shadows
[Re: hopfel]
#372717
06/03/11 19:54
06/03/11 19:54
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
http://tinyurl.com/42jzmdeI think I mention all you need there. An example would probably help you faster, but won´t make you understand why it works the way it does... And still, I would recomment just manipulating the textures. Overlapping of things can btw be done by a different depthorder for example...
|
|
|
Re: 2D Shadows
[Re: Slin]
#372738
06/03/11 21:45
06/03/11 21:45
|
Joined: Dec 2008
Posts: 605 47°19'02.40" N 8°32'54.67" E...
hopfel
OP
User
|
OP
User
Joined: Dec 2008
Posts: 605
47°19'02.40" N 8°32'54.67" E...
|
I know the basics already, I lerned them 4 years ago. I was looking for a way to change the size of an array at runtime, and...
...well, like always I ask something in this forum, I found the solution in the manual myself. And like always I feel like a total jerk. Argh... o.-'
The perfect answer to my question was in the example to sys_malloc, but I always just looked for malloc, where I, of course, found nothing helpful. Now I understand and it works.
Thx for helping.
Hilf mir, dir zu helfen!
|
|
|
Re: 2D Shadows
[Re: hopfel]
#372741
06/03/11 21:59
06/03/11 21:59
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
I know the basics already, I lerned them 4 years ago. I was looking for a way to change the size of an array at runtime, and... You can't say you know the basics without knowing how to allocate and re-allocate memory at runtime oO
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
|