Re: Using handles in bgt somewhat confuse me

2016-01-06 Thread AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

That's good Omar. Good luck and have fun.

URL: http://forum.audiogames.net/viewtopic.php?pid=245741#p245741





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2016-01-05 Thread AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

Greetings all,I seem to understand fully the basics of using classes and handles, thanks to your help. I will be sure to give you all credit in my future projects.Also, given the slow speed at which this site will probably load, you will most likely be in the year 2019 by the time it posts, lol.Thanks guys!

URL: http://forum.audiogames.net/viewtopic.php?pid=245693#p245693





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2016-01-02 Thread AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

hi,I think I've made some progress, however I'm at a bit of a roadblock I don't know how to think through.I've begun making a simple silly space invaders thing I'll not release its just a test for me, and already I've run into a problem.Here is how it is supposed to work.I have a spawn timer which spawns drones every 5000 ms, using a class.When a drone is called, it is built with a spawner function.While the drone is alive (i.e not landed or not shot not working yet), it falls to the ground using drones.fall, a method inside the drones class.But when the first drone lands, all hell reveals itself. Drones land in the completely wrong location as to where they were called, as previously existing drones fall they get panned as new ones are called, and the entire thing just becomes a large bit of confusion.I've determined it has something to do with destroying drones that land, because otherwise if I didn't well, a funny thing happens. They go underground, playing there landed sound, rofls.Since this project has an include to help speak to screen readers (thanks Kyle), You might need to download the entire directory as a zip. If you just want to have a quick look at the code, it is pasted here.If someone can help un-break this mishmash of code, that would be greatly appreciated.If you have found yourself at the mercy of the forum and it broke the code in bad ways, there is a dropbox link that will allow you to download the code and its respective sounds.https://dl.dropboxusercontent.com/u/954 … 20test.zipEdit: Ehh. The forum does not like me posting code. I'll post a txt version of the code so it is viewable quicklyhttps://dl.dropboxusercontent.com/u/95411135/game.txt

URL: http://forum.audiogames.net/viewtopic.php?pid=245114#p245114





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2016-01-02 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

To post code without the forum complaining, surround it in [ code ] tags. But without the spaces, since that particular tag is the only one I can't figure out how to escape.

URL: http://forum.audiogames.net/viewtopic.php?pid=245128#p245128





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2016-01-02 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

To post code without the forum complaining, surround it in [ code ] tags. But without the spaces, since that particular tag is the only one I can't figure out how to escape.I'm not sure why it isn't working as-is. I'd try adding a line like this after board[i].fall(), but it doesn't really answer the question of what's currently wrong:if([ a-t ](board[i]) != null and board[i].height<=0) [ a-t ](board[i])=null;

URL: http://forum.audiogames.net/viewtopic.php?pid=245128#p245128





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2016-01-02 Thread AudioGames . net Forum — Developers room : sneak via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

You're using the same sound object for each drone I'm guessing. I haven't looked at the code yet, but from your description of what's going on it's the first thing that comes to mind.You'll want to stick the sound object into the drone class.so like thisclass drone{sound droneSound;droneSound.load("sounds/drone.ogg");}Then put this in the main loopdrone.droneSound.play();drone.droneSound.pan(position);Position is your drone's position on the board. I'll go ahead and have a look at the code now, sorry if this wasn't the right answer.

URL: http://forum.audiogames.net/viewtopic.php?pid=245172#p245172





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2016-01-02 Thread AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

Ugh. Seriously? *Slaps self in face* how the hell did I not notice that...thanks sneak for seeing that simple mistake rofls. Seriously, I was about ready to scrap the code and try again.Thanks to all of you who have posted! Your help got me this far. Again, thank you so much guys!Btw, if anyone cares, ANSIC stands for another space invaders clone.

URL: http://forum.audiogames.net/viewtopic.php?pid=245181#p245181





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2016-01-02 Thread AudioGames . net Forum — Developers room : sneak via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

Heh, seems your problem was a lot simpler actuallyYou had your values swapped out.pool.play_2d("sounds/drones/1/land.ogg", playerpos, 0, pos, height, false, false);If you replace what you had with that you'll be all set.

URL: http://forum.audiogames.net/viewtopic.php?pid=245174#p245174





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-31 Thread AudioGames . net Forum — Developers room : sneak via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

I think a simpler way of defining it is by comparing it to the phrase "that one". Extremely vaigue without some kind of context, like a finger pointing. So the phrase stays the same, but what you're refering to doesn't. So I like that one and pointing to a red honda civic in a line of red honda civics, with the only difference being that this one has 32000 less miles on it than the rest. I think that's a good analogy, Let me know if I'm completely wrong though.

URL: http://forum.audiogames.net/viewtopic.php?pid=244885#p244885





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-31 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

Python does use them, it just doesn't tell you so as to avoid the headache. Most languages do.Think about how a program uses memory.I'll explain how it works in C, because there's lots of layers when you get to dynamically typed languages like Python, but I think the principal stays the same.To create a variable, it allocates a chunk of memory, based on the amount of memory required by the type.For example:int x;Marks 32 bits of memory to be used for the x variable.x=5;Changes the value of those 32 bits.A pointer / handle to x:int* p=x; // I don't actually remember how to get pointers because I haven't used C since last October.The value of p is the address of the memory where x starts.So you get these different scenarios:int sum(int a, int b) {return a+b;}void increment(int* a, int b) {+=b;}In the first case, the function takes the 
 value of the variable, rather than its address, and returns a new variable.In the second case, the original variable is changed, because the function takes a pointer to the memory where it is stored.Most object oriented languages will send the values, and not the addresses, when using primitives like int / float, and will send the addresses when dealing with objects and arrays (including strings). Angelscript is one of the weird cases where it only does it halfway, and we have to use handles. (I get the impression that angelscript's purpose is to be C++ without all the cosmic horror of C++, making it kinda weird for BGT.)In summary: a handle and a pointer and a naked object in most object oriented languages are really just ints containing the memory address where the actual object's data is located, because why would you outright copy most objects anyway? (Actually, even BGT doesn't seem to let you outright copy objects with a=b. I'm not even 
 sure if you can do that easily in c++... but I think I can write a function to clone arbitrary C structs?)The weird edge case is strings. THey are not primitives. They are sometimes byte arrays, sometimes their own class of object, but always get special treatment because they are the one case that everyone really does need to copy and modify all over the place.

URL: http://forum.audiogames.net/viewtopic.php?pid=244884#p244884





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-31 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

Python does use them, it just doesn't tell you so as to avoid the headache. Most languages do.Think about how a program uses memory.I'll explain how it works in C, because there's lots of layers when you get to dynamically typed languages like Python, but I think the principal stays the same.To create a variable, it allocates a chunk of memory, based on the amount of memory required by the type.For example:int x;Marks 32 bits of memory to be used for the x variable.x=5;Changes the value of those 32 bits.A pointer / handle to x:int* p=x; // I don't actually remember how to get pointers because I haven't used C since last October.The value of p is the address of the memory where x starts.So you get these different scenarios:int sum(int a, int b) {return a+b;}void increment(int* a, int b) {+=b;}In the first case, the function takes the 
 value of the variable, rather than its address, and returns a new variable.In the second case, the original variable is changed, because the function takes a pointer to the memory where it is stored.Most object oriented languages will send the values, and not the addresses, when using primitives like int / float, and will send the addresses when dealing with objects and arrays (including strings). Angelscript is one of the weird cases where it only does it halfway, and we have to use handles. (I get the impression that angelscript's purpose is to be C++ without all the cosmic horror of C++, making it kinda weird for BGT.)In summary: a handle and a pointer and a naked object in most object oriented languages are really just ints containing the memory address where the actual object's data is located, because why would you outright copy most objects anyway? (Actually, even BGT doesn't seem to let you outright copy objects with a=b. I'm not even 
 sure if you can do that easily in c++... but I think I can write a function to clone arbitrary C structs?)The weird edge case is strings. They are not primitives. They are sometimes byte arrays, sometimes their own class of object, but always get special treatment because they are the one case that everyone really does need to copy and modify all over the place.If it helps, you can think of memory as an array of bytes. A pointer is the index in that array where a variable starts. A handle is a little higher level, so it probably contains a little more information, but functions close enough to identically.(Memory is not actually an array of bytes, but sorta kinda is sometimes... it gets complicated. Actually, in C, the index operator used in arrays is really just telling it to check the address of the start of the array plus the index. It's basically addition for pointers. This is exactly as ripe for ridiculous puzzles and hacks and IOBEs as it sounds.)

URL: http://forum.audiogames.net/viewtopic.php?pid=244884#p244884





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-30 Thread AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

maybe this is taking this off topic, if so give me a proverbial slap on the wrist, but i've never understood what exactly a handle is. it probably just my unfamiliarity with c type languages, but could someone explain it? and maybe while your at it why python doesn't use them?

URL: http://forum.audiogames.net/viewtopic.php?pid=244851#p244851





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-29 Thread AudioGames . net Forum — Developers room : sneak via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

You can also use inheritance. Also keep in mind that if you stick a timer object in the robot class, each robot will have its own timer that you can check and reset.

URL: http://forum.audiogames.net/viewtopic.php?pid=244694#p244694





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-29 Thread AudioGames . net Forum — Developers room : Lucas1853 via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

What I do is:class robot{int integrity;int speed;int pos;//constructor will be placed here. I like using a constructor like this, because I can call enemies of varying strengths and speeds.robot (int init_integrity, int init_speed, int init_pos){integrity=init_integrity;speed=init_speed;pos=init_pos;}//methods can go here.}robot@[] robots;void create_normal(){robot r1(50, 1000, 15);robots.insert_last(r1);}void create_dDay(){robot r1(350, 450, playerpos+random(30, 45));robots.insert_last(r1);}void create_custem(int integrity, int speed, int pos){robot r1(integrity, speed, pos);robots.insert_last(r1);}Keep in mind I haven't tested this, so it might have compilation errors. If you don't understand it, I can explain it more but basicly depending on what function you call it will create a diff
 erent type of robot and add it to the array of robots. You could also have a "string type;" along with all your other variables if you need to tell the difference, and for each new type you can just create a new function based on the first 2.

URL: http://forum.audiogames.net/viewtopic.php?pid=244632#p244632





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-29 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

You will probably never need more than one timer. You can use multiple timers, if you want, but in practice, what matters is the interval between frames.This does get weird when dealing with integer precision, rather than floats or doubles. In that case, you could include a timer property in the enemy class. What I would do is just include a number (probably a double, but a float or int would work, too) as a property of the enemy class, then have a method that updates it. Why not a timer instead? ... Well, mostly habit; I'd probably use timers more if I started with BGT.What you will ultimately wind up doing is iterating over a collection of enemies and updating them. The easiest way is to use an array and a for loop.The question is, what should you make into a method of the enemy class, and what should be handled elsewhere? I usually decide based on how reusable I want the code to be. I didn't really plan on making JLA or Sengoku Jidai expand
  beyond those single games (this might have been a mistake), so the character and map classes don't do much. OTOH, the engine used in DBGU and Jeqo Prime was always very open-ended, so most of the essentials are handled in the Fighter class, and only game-specific details are handled elsewhere. (I have like five other games that are minor variations on this idea, but I can't share them because reasons.)But what makes my brain confused is, how do I tell the engine which robot has just hit the player, or what robot needs to have something at all special happen, like die or be hit by the players force?You could give the robots names, or try to identify them based on their properties. After all, they have very different stats in the example. (I'd probably use names or an int ID, but I do like saving space, so checking stats works, too.)

URL: http://forum.audiogames.net/viewtopic.php?pid=244622#p244622





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-28 Thread AudioGames . net Forum — Developers room : sneak via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

They're a little weird, but if you just play around with them you'll figure it out. The main use I've gotten out of them is when creating object arrays. Seriously, they're useful.Here's an example, maybe it'll be helpful, maybe not.sound@ [] sounds; //Creates an array of sound objects with 0 entries.void main(){show_game_window("Testing handles");do{if(key_pressed(KEY_SPACE)){if(sounds.length()<10)//This will prevent there from being more than 10 entries created in the array.{sounds.insert_last(sound());//Creates a sound object and places it at the end of the array.int entry=sounds.length()-1;//Gives us a variable to reference the last entry so we can load and play it.sounds[entry].load("c:\\windows\\media\\ding.wav");//Load the file into the sound object located within the sounds array.sounds[entry].play_looped();//Plays the sound in a loo
 psounds[entry].pan=-100;//Gives all sounds a base pan of -100;}}for(uint x=0; x<sounds.length(); x++){sounds[x].pan=(x+1)*20-100;//Sets the pan value of the x entry of the array to mirror its location in the array.sounds[x].pitch=0+10*(x+1);//Changes the pitch to reflect the entry's location within the array;}}while(!key_pressed(KEY_ESCAPE));}If you paste this example into a notepad and rename it to a .bgt file and run it, you'll notice that the sounds pan from left to right as you press the spacebar, and also increase in pitch as they go from left to right. This was all done by using an array with 0 entries. I didn't have to create a single object in the script itself. I just create a template in which the script could create its own objects. Like I said extremely useful.HTH.

URL: http://forum.audiogames.net/viewtopic.php?pid=244524#p244524





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-28 Thread AudioGames . net Forum — Developers room : sneak via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

They're a little weird, but if you just play around with them you'll figure it out. The main use I've gotten out of them is when creating object arrays. Seriously, they're useful.Here's an example, maybe it'll be helpful, maybe not.sound@ [] sounds; //Creates an array of sound objects with 0 entries.void main(){show_game_window("Testing handles");do{if(key_pressed(KEY_SPACE)){if(sounds.length()<10)//This will prevent there from being more than 10 entries created in the array.{sounds.insert_last(sound());//Creates a sound object and places it at the end of the array.int entry=sounds.length()-1;//Gives us a variable to reference the last entry so we can load and play it.sounds[entry].load("c:\\windows\\media\\ding.wav");//Load the file into the sound object located within the sounds array.sounds[entry].play_looped();//Plays the sound in a loo
 psounds[entry].pan=-100;//Gives all sounds a base pan of -100;}}for(uint x=0; x<sounds.length(); x++){sounds[x].pan=x*20-100;//Sets the pan value of the x entry of the array to mirror its location in the array.sounds[x].pitch=0+10*x;//Changes the pitch to reflect the entry's location within the array;}}while(!key_pressed(KEY_ESCAPE));}If you paste this example into a notepad and rename it to a .bgt file and run it, you'll notice that the sounds pan from left to right as you press the spacebar, and also increase in pitch as they go from left to right. This was all done by using an array with 0 entries. I didn't have to create a single object in the script itself. I just create a template in which the script could create its own objects. Like I said extremely useful.HTH.Edit, cleaned up the formula that set the pan and pitch locations.

URL: http://forum.audiogames.net/viewtopic.php?pid=244524#p244524





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-28 Thread AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

woah, sneak, that's cool!It kind of creates a musical harmony that's off sync with itself but the way it sounds is quite cool.Ok, so let's say, I have a class of robots.class robot{int integrity;int speed;int pos;//constructor will be placed here. I like using a constructor like this, because I can call enemies of varying strengths and speeds.robot (int init_integrity, int init_speed, int init_pos){integrity=init_integrity;speed=init_speed;pos=init_pos;}//methods can go here.}Ok, that's fine and everything.So let's say I need to declare a robot of type, uh, I don't know, let's just call it robotAlpha, for now.robot robotAlpha(50, 1000, 15);I set robotAlpha's integrity to 50, it's speed to 1000 (slow robot), and its position to 15 almost completely on the left depending on how big the board is.Now, let's spaw
 n another robot of type doomsday machine which won't be all badass as it sounds here.robot dDayMachine(350, 450, playerpos+random(30, 45)); //makes the robot spawn depending on wherever the player will be, roughly. I could have of course given it a direct position, but felt it needed to spawn close to the player.Now, we have two robots one standard, one which could possibly take over the world a.to make them move, ideally you would want to give them there own speeds, but something I'm not so sure of, can I get away with using one single timer for multiple enemies of the same class?My guess is no, because then everything on screen would suddenly go flying across the stage as the timer elapsed and restarted.Or furthermore, not only would it not work properly, but I'm also guessing the timer would restart far before some enemies got the chance to move.Which also leads me to a very important question.To pull this off, I am the
 orizing I'm going to need a bunch of handles to check where each robot is on the stage.Yeah, I guess I could assign two handles one to the regular robot, and one to the doomsday machine.But say a random robot with random attributes spawns every 5000 ms (5 seconds), to make our lives more difficult.I'm guessing then and there would be the time to use an array of handles?But what makes my brain confused is, how do I tell the engine which robot has just hit the player, or what robot needs to have something at all special happen, like die or be hit by the players force?

URL: http://forum.audiogames.net/viewtopic.php?pid=244597#p244597





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-28 Thread AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

Well, let's use your dDay machine.First you'd of course have an array of robots, right?robot@[]robots();That's great! Now, you created your dooms day machine.robot dDayMachine(350, 450, playerpos+random(30, 45)); //makes the robot spawn depending onNow guess what we do? We put that mug in the array.robots.insert_last(@DDayMachine())

URL: http://forum.audiogames.net/viewtopic.php?pid=244602#p244602





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-27 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

This part is indeed bizarre and confusing and most languages tend to just simplify it by making all object references into handles by default.I think it's easier to figure out by trial and error. Does the script do something weird? Try throwing in at signs.Here are the cases I can think of OTTOMH:(Eh, remember that the forum sometimes filters the at sign into [a-t] to help protect people from email spammers.)Comparing objectsYou'll usually want to check two handles to see if they're pointing to the same object, rather than creating your own opCmp method to determine if two objects are clones of each other.So if you have two object handles A and B, you'd compare them like so:if(@a==b)orif(@a==@b)(It's kinda confusing if you do or don't need the at on the right side of the equals. -_- )You can usually get away with just putting the at sign at the beginning of the co
 mparison. I think the compiler use to give you warnings that it was converting the right side for you, but people did this so often out of convenience that Philip disabled that warning.There are two particular cases that do this in opposite ways.If you want to check if a handle is null, just do this:if(@A==null)However, if you want to check a handle inside an object's methods, say, if you want to see if an attack hits every target on the map and you want to skip the object that's performing the attack, you might do this:if(@target==@this)I think this is the only case where you need handles on both sides.AssignmentIf you want to assign a reference to a handle (and you usually do, unless they're temporary objects or fixed global objects), you have two ways of doing it.If you're doing this when declaring the object, you would do it like so (my_class is a class):my_class temp;my_cl
 ass@ handle=temp;Or, if you're assigning to a preexisting handle:my_class temp;@handle=temp;(Actually, I don't know if it matters whether there is a space between the at sign and the variable name or not.)You'll inevitably want objects to remember other objects. For example, a map class containing an array of enemies or items, and maybe references to neighboring maps. You might define such a class like so:class map {
enemy@[] enemies;
item@[] items;
map@ north=null, south=null, east=null, west=null;

// (More properties, Constructors, etc.)

void setNorth(map@ onNorth) {
   [ a-t ](this.north)=onNorth;
   // Or, you can just say @north=onNorth.
}

void addEnemy(enemy@ e) {
   this.enemies.insert_last(e);
}

bool hasNorth() {
   return [ a-t ](this.north)!=null;
}

}You can't have object properties inside classes; they must be handles. Which basically means throw an at sign into the declarations, assignments, and comparisons.This leads to one complaint I have about BGT/angelscript, which is the lack of a built-in way to initialize handles.In java and _javascript_ and many other languages, you can do this:handle=new my_class();In Python, you can do this:handle=my_class()In BGT, you need to create a temporary object, and set your handle to point toward it. Since I use handles for nearly everything, this is so needlessly tedious that I usually write my own functions that work like the new command.my_class@ new_my_class() {  my_class ret;  return ret;}Then I just say@handle=new_my_class();whenever I need a new one.Yes, that is indeed even more tedious if you use multiple constructors.Oh, and dictionaries. If 
 you keep objects in dictionaries, it will break if you don't use a handle to retrieve it. I can never remember how this works and just copy from the couple times I did it right. I think it works like:my_class@ result;dict.get(key, @result);(Actually, I got confused and copied from the time I got it to work, again.)

URL: http://forum.audiogames.net/viewtopic.php?pid=244484#p244484





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Using handles in bgt somewhat confuse me

2015-12-27 Thread AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector


  


Re: Using handles in bgt somewhat confuse me

A handle can be in 2 states: it can be uninitialized, or it can point to an object of that type.Monster monster;Monster@ monsterHandle; // an uninitialized handle that can point to any monster@monsterHandle = monster; // monsterHandle now points to monstermonsterHandle.kill(); // this is the same as monster.kill()

URL: http://forum.audiogames.net/viewtopic.php?pid=244479#p244479





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector