Hello all.
Over the upcoming Christmas break, I plan to do a little work with AGS, but since the last version I worked with to any real degree was v 256d, I'm a little out of date.
I notice these snazzy new "module" thingies, and they look pretty cool. A quick question or two about them.
1) For mini-games, is it practical to write a module to handle all my calculations that would normally clog up my room's repeatedly execute code. (It would be wonderful if this were the case -- some of my older arcade code has so many variable checks and if/then lines that the repeatedly execute becomes pretty damn unwieldy to work with after a while. It would be nice to have a place to shuttle most of that code to.)
2) If so, can a module do something simple like calculate if the player smashed his bumper car into NPC player, calculate damage, and then reduce those hit points from the player's health integer? In other words, can a module change the value of a global integer or other defined variables?
Also, the game I'm planning is something like a table top wargame. You move your little pieces around while the computer does the same. Then they fight it out for the rest of the turn. I got a pretty decent little version of this working under the old AGS, but I want to expand it to larger battles (say 20+ units for each army). I know that the limit for objects and characters on screen is something like 50, max. But I would also like to have little labels floating over the little army men's heads so it's easier to keep track of everything. This will push it beyond the limits, so I'm looking for a workaround.
3) Do the Dynamic Sprites count towards this limit? And if not, how many labels could I create this way?
4) If this isn't feasible, I guess I could use the old "mouse over character / object displays its name and stats on a GUI" trick. Is this possible in the new AGS or is the mouseover function limited to hotspots?
Thanks for any attention to these questions. I thank you in advance. :)
UPDATE: Tried a version of Gilbot's suggested code and it seems to do the trick!
Ponch
1) Modules can have their own rep_ex and rep_ex_always functions, so it would be reasonable to outsource some of your code into modules.
2) Modules can access global ints declared in the current or previous modules. They don't have access to variables defined in the global script because modules are compiled before the global script. You can simply move the variable to the module script and the import to the module header and it will have access.
3) AFAIK, there is no limit to DynamicSprites (aside from physical memory), but they definitely don't impede on character or object limits. However DynamicSprites aren't automatically drawn on-screen, you'd have to use an Overlay or set a GUI[Control]'s graphic to the Graphic property of the DynamicSprite (note that if the DynamicSprite pointer goes out of memory the sprite is lost). I hope I haven't lost you completely here.
Anyway...I'm slightly distracted by this girl I met...(what is this? I'm happy? WTF?!?!?)...I could have given you false/misleading/idiotic information. Welcome back Ponch!!!!!!!! :=
Thank you, Monkey_05_06, very helpful.
Another question, what would be the easiest way to check (in repeatedly execute) if an enemy marker (sprite or object) has moved to within 40 pixels (in any direction) of one of the player's markers using the snazzy new 2.7 code?
My family thanks you in advance for helping me now so I can spend more Christmas time with them over vacation. ;)
- Ponch
Depends on how you define "within 40 pixels", whether it's 1. "within 40 in x coordinate or within 40 in y coordinate", 2. "within 40 in x coordinate and within 40 in y coordinate" or 3. more commonly, "within approximately 40 in distance".
For example, to do 3., just use Pythagoras' Theorem, like:
dist=(object[1].X-player.x)*(object[1].X-player.x)+(object[1].Y-player.y)*(object[1].Y-player.y); //x^2 + y^2
if (dist < 1600) { //40^2=1600
blah bla bla...
}
Quote from: Gilbot V7000a on Mon 06/11/2006 03:27:10
For example, to do 3, just use Pythagoras' Theorem...
Holy cow! Algebra just saved Christmas!
Thank you, Gilbot v7000a! Of all the Gilbots who could have become self-aware, I'm glad it was version 7000a! If robots celebrated Christmas, I would leave milk and cookies out for you!
- Ponch