Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - PMick

#1
I've spent the last few hours trying to figure out how to do this--been on multiple help sites, including these forums, trying to figure this out and at last I'm throwing in the towel and asking for help.

Here's what I want to do: I have several objects on the screen. I want the player to be able to click on any of these object and have it rotate 90 degrees, keeping that position until the player clicks again to rotate it another 90 degrees. The most obvious way to do this, as far as I can tell, is with an array of DynamicSprites and the DynamicSprite.Rotate command. The problem I'm running into is that I need the DynamicSprite array to be global, so that the effect of clicking an object can last until the player changes it again.  I've tried several different ways to declare the DynamicSprite array outside the function, including in game_start, but when I try, inside the function, to change the values in the array, I'm told I can't assign initial values to a global variable.

I don't necessarily have to use DynamicSprites for this, but I'd like to as it seems like that would be the most efficient coding. The other way I know of to do this would be to have 4 different sprites (created from images I manually rotate myself) for each object, but there are 25 objects on the screen, and my plan is to have several different screens set up this same way. So while this method would avoid the frustrations of DynamicSprites, it would involve making literally hundreds of sprites and taking a very long time.

I'm really hoping there is a way to do this with DynamicSprites, to save me the hours of manipulating graphics. Can someone help me? Again, the goal is to have 25 objects on the screen, and every time the player clicks one, it rotates 90 degrees and stays that way until clicked again.
#2
My apologies if any of this is redundant.  I DID run a search for some of my questions regarding structs and arrays and I'm still not entirely certain of the best way to do what I'm trying to do.  If I've made any mistake in posting this, I hope you'll all chalk it up to newbie inexperience.

I am in a bit of confusion about the best way to do what I'm trying to do given the way array sizes work. What I want in my game is this: there is a specific type of game entity (we'll call it a Beef, since I like beef). Now, each Beef has a set of variables that are essentially randomized when a Beef is created. At the beginning of the game, there's only one Beef. However, more Beefs will be created through the player's actions.  That is to say, the player has the power to tell the game to generate a new Beef from time to time. In addition, from time to time Beefs may be destroyed, either by the player or by the game.  This means (a) I as the programmer don't know beforehand how many Beefs will be in any given game, and (b) the number of Beefs will change very often in any given game. After browsing through the AGS help file, it seemed to me that an array of structs was the best way to go. However, as far as I can tell, a normal array in AGS code has a set size declared upon creation. I read the bit about "dynamic arrays", but according to the help file these cannot include structs, and the data within them gets erased any time you change the array size anyway.

So, what is the best way to handle this situation? One thought that occurred to me was just to make the array size massive right from the start--i.e. "Beef beefs[10000000];", and then leave all unused Beef variables empty until new Beefs are generated by the player.  What would be the effects on memory if I did this?  Would this create a huge unwieldy bit of data that would slow down game speed, for example?  Also, this method still has a flaw--although the max is very very high, a max still exists. Ideally I'd like it to be possible for the game to go on forever if desired, so that a player could (in theory) create Beef after Beef after Beef in a very Beef-filled universe (ok, now I'm hungry...)  Is there anyway I can do what I'm trying to do and have there NOT be a limit (beyond the player's machine's computing ability, anyway)?

Again, my apologies if this post is redundant or if the information I need could have been obtained some other way.  I appreciate any help the more experienced folks here could give me--thanks in advance!
SMF spam blocked by CleanTalk