Old 26th February 2004, 03:07   #1
OnionRingOfDoom
Member
 
OnionRingOfDoom's Avatar
 
Join Date: Nov 2003
Location: Brookly, NYC
Posts: 72
Send a message via AIM to OnionRingOfDoom
Unhappy global variable problem

Ok, I got a large problem here. I am working on a AVS port of the classic Space Invaders arcade game. Now, in the first level, there is a total of 55 enemy sprites on screen. However, each sprite uses 3 global variables: 1 for x possission, 1 for y possission, and 1 for whether it exists or not (IE, whether you have destroyed it or not). Plus, I have a bunch of other global variables (about 20) for various things such as mouse possission, state of the left mouse button, and whether or not your mouse is in the AVS window or not (the game goes into a demo mode if your mouse is not in the AVS window). In total, I would need about 185 global variables.

Now, the enemies are in one giant rectangular group, consisting of 5 rows of 11 sprites. Each row is a different enemy. Would it be possible to do each row as an array? I have no idea how to use the gmegabuf() functions, and yes, I searched the forum, yes I downloaded and looked at the example files, and yes, I still don't understand it.

PS: Hi #ff guys! I got kicked off the internet for 2 weeks (due to going over the bandwidth limit too many times) last Friday, so I should be back next weekend and such. Oh, and I'm using a library computer to type all this.
Attached Files
File Type: zip onionring - space invaders.zip (4.0 KB, 176 views)
OnionRingOfDoom is offline   Reply With Quote
Old 26th February 2004, 17:33   #2
Shock Value
Senior Member
 
Shock Value's Avatar
 
Join Date: Aug 2002
Location: USA
Posts: 158
This should definitely be possible. Just make a multidimensional array with gmegabuf(). You can assign variables to it like this (example):

assign(gmegabuf(5000*c+25*r+v),number)

c=column number (from 1 to 200)
r=row number (from 1 to 200)
v=variable (25 variables are available for each row/column position).

And 'number' would be the value that you are assigning to the variable. Also, you can tweek the constants (5000 and 25) to have different limits for each dimension. Just keep in mind that gmagabuf() can only handle a maximum of 1,000,000 variables (I think).
Shock Value is offline   Reply With Quote
Old 26th February 2004, 17:36   #3
OnionRingOfDoom
Member
 
OnionRingOfDoom's Avatar
 
Join Date: Nov 2003
Location: Brookly, NYC
Posts: 72
Send a message via AIM to OnionRingOfDoom
OOH! I think I am beginning to understand this whole array thing! Thanks! Oh, and what is the 5000 for? Also, for v, would I just put a variable name?

Now if I could only figure out how to work the movement for the enemies...
OnionRingOfDoom is offline   Reply With Quote
Old 26th February 2004, 22:29   #4
OnionRingOfDoom
Member
 
OnionRingOfDoom's Avatar
 
Join Date: Nov 2003
Location: Brookly, NYC
Posts: 72
Send a message via AIM to OnionRingOfDoom
(Dang edit limit, I hate double-posting.)

The problem seems to be that I don't know how to set up a multidimensional array.
OnionRingOfDoom is offline   Reply With Quote
Old 27th February 2004, 05:45   #5
Jaheckelsafar
Major Dude
 
Join Date: Feb 2002
Location: home
Posts: 1,318
here it is in quick.

Use one array, but break it up in your head.

instead of XXXXXXXXXXXXXXXXXXX
think of XXXXX XXXXX XXXXX XXXXX

You can index the above example with something like index=row*5+col

Stoke me a clipper. I'll be back for Christmas.

- Arnold Rimmer
Red Dwarf
Jaheckelsafar is offline   Reply With Quote
Old 27th February 2004, 10:54   #6
piR
Senior Member
 
piR's Avatar
 
Join Date: Feb 2003
Location: France
Posts: 108
BTW, I really can't see why you need such an array !
IMO, the only useful global variables are :
- the status of a sprite : Killed, Stationary, On attack,
- the current position of a line of sprites : each sprite coordinates are computed depending on its state (K: nothing, S: static offset, O: dynamic offset),
- the coordinates of the shots : to know if someone has been hit,
- the status of each wall (if you manage them),
- the mouse coordinates and state (not really, in fact, as they are only useful for your ship ...).

Knowing all the coordinates of all the ships is only meaningful if you want to manage collisions between them ...

Try my AVS packs piR One and piR Two.
Take a look to my last presets on my web site.
piR is offline   Reply With Quote
Old 27th February 2004, 14:31   #7
OnionRingOfDoom
Member
 
OnionRingOfDoom's Avatar
 
Join Date: Nov 2003
Location: Brookly, NYC
Posts: 72
Send a message via AIM to OnionRingOfDoom
well, the way each sprite works is a bit complicated. Don't bother downloading the attachment I posted, cause it's old and I redid the entire sprite system. And since each sprite is animated on beat, I have 2 effects list, and one is enabled and the other is disabled every other beat. Therefore, I need two more variables for the on beat movement so that the movement of the sprite in the first effects list transfers over to the second.

Each sprite uses 5 global variables:

- whether it exists or not (IE, you killed it)
- X posission
- Y posission
- On beat X movement
- On beat Y movement

Now, 55*5=275. IE, I need 275 global variables, and I only have 99 without using the gmegabuf(), which I still have no idea how to work.

And I need to know the cordinates of each sprite so that I can tell if the shot has hit the sprite or not. IE, if the cordinates of the shot equal the cordiantes of the sprite, then said sprite has been hit.
OnionRingOfDoom is offline   Reply With Quote
Old 27th February 2004, 15:51   #8
Jaheckelsafar
Major Dude
 
Join Date: Feb 2002
Location: home
Posts: 1,318
I think you only realy need the position of one and can derive the position of the rest relative to that one. Then you only need keep whether the ship still exists global.

Stoke me a clipper. I'll be back for Christmas.

- Arnold Rimmer
Red Dwarf
Jaheckelsafar is offline   Reply With Quote
Old 28th February 2004, 17:18   #9
OnionRingOfDoom
Member
 
OnionRingOfDoom's Avatar
 
Join Date: Nov 2003
Location: Brookly, NYC
Posts: 72
Send a message via AIM to OnionRingOfDoom
Hmmm, interesting, but how would I keep whether the ship still exists global? If I destroy the ship that all the other ship's movements are based off of, then all the other ships would disapear as well, right?
OnionRingOfDoom is offline   Reply With Quote
Old 1st March 2004, 11:50   #10
piR
Senior Member
 
piR's Avatar
 
Join Date: Feb 2003
Location: France
Posts: 108
The fact that the ship still exists or not has nothing to do with its position on the screen. It is always computed but you just don't draw anything if it doesn't exist anymore (using skip=1 or n=0, if you use a superscope).

Try my AVS packs piR One and piR Two.
Take a look to my last presets on my web site.
piR is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > AVS > AVS Troubleshooting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump