Re: Newb Needing Help With Classes In BGT

Hello there ross,
If memory serves me right there is indeed a tutorial, although a very short one, on classes in the in game practice tutorials in bgt.
That one left me with a lot of questions. In the end, I ended up instead of looping through the entire board array as they want you to do in the tutorial,
I used an array for each class, and the array is simply a list of all the class members, if you will.
So what this means is, from personal experience anyway, is that you can put a class item anywhere, even on top of an already existing class item, and if you have code to check that, nothing too bad will happen.
If you use the slightly dirtier method, (to me) you can spawn as many class items as you want, however be aware if your following the tutorial for the in game practice, things could get interesting.
so here is what I do for all my classes, doctored for the situation here.
trampolines@[]trampoline; //creates an array of trampolines. I thin k
class trampoline
{
int x, y; //add any additional variables you want here.
trampoline(int init_x, int init_y) //This creates a class constructor, so you can specify values where a trampoline can go
{
x=init_x;
y=init_y;
}
//any functions you want for the class will go here.
}
Now, when you want to spawn a trampoline, what I do anyway, is this:
In a function where spawning related things will happen, or wherever you want the trampoline to be able to be created, you can put this:
trampoline tramp(desired_x, desired_y);
trampolines.insert_last(tramp);
Now, you have a trampoline that is ready to be used.
Now, to check that a player is near or on one, you simply loop through all of them in a forloop in a function, hopefully where player movement is being performed.
In the forloop you do your if checks if player x and y equal a trampoline x and y.
I can't really give you an example of that spe cific thing since the forum keeps eating it up rargh.
Eh, there might be some slight issues with the code and my braces might be off I'm using firefox to compose this reply, but there you go.
Hope this helps and isn't too terribly confusing. I know how confusing classes can be, and will be willing to help as much as I can.

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ross via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector

Reply via email to