2017-04-18 04:41:59

Hello.
Can you please tell me how to make a bullet class in BGT?
Thanks in advance!

2017-04-18 05:39:46

Hi Jonikster.
First you go back and forth between pygame and pyglet, now bgt? I've seen you do this multiple times, why don't you pick one or the other, bgt or python? I'm not saying this to be rude, your going to get really confused and have a hard time if you keep switching back and forth like this. I can't help you with this class I don't use bgt. If you practice making these things you will be able to figure these things out yourself. Plus, if you keep on asking people to give you code, you'll never learn what you need to know, and you won't be able to code for yourself.

Guitarman.
What has been created in the laws of nature holds true in the laws of magic as well. Where there is light, there is darkness,  and where there is life, there is also death.
Aerodyne: first of the wizard order

2017-04-18 11:31:21 (edited by JessicaGG 2017-04-18 11:31:51)

Hi.
Agreed with Guitarman. To be honest, you, "Guitarman" just summarized what i would have said to this community since bgt became free.
The point with programming is to create something from your imagination, not taking some others work and releasing it as your own.
This is not ment
to be offensive but thats the truth.

If you like what I do, Feel free to check me out on GitHub, or follow me on Twitter

2017-04-18 16:52:23

About Python. I use BGT for offline projects. Python learn for online

2017-04-18 17:21:56

Hello. Well you may do the following:
First you need to write a class, which has veriable x, y, and z in it.
And then you need to handle your class with an array so you may perform stuff to all of your objects(bullets):
we assoom that your bullet class named bullet so you may do like this:
bullet@left braket right braket bullets;
then the hoe class starts here:
class bullet
{
int x; //X of your bullet
int y; //Y coords of your bullet.
int z; Z of your bullet
int speed; //How fast your bullet travels, In mili seconds.
int range; //How much your bullet should travel. Like 50 tiles or ...
int distance; //How much tiles the bullet passed. This veriable is used to help you when you want to stop your bullet when it goes out of range.
Then your constructor goes here, with the veriables you need.
to be honest, This kind of bullet system can be a bit confusing for you, But that's more realistic as it spawns an object and this object moves until it ritches it's destination.
And this is how your bullet will move around:
a for loop goes to another function that should be called in your while loop
like this:
for(uint i=0; i<bullets.length(); i++)
{
if(speedtimer.elapsed>=speed) //to move the bullet based on its speed
{
speedtimer.restart();
//And now, the code of moving goes here. Like bullets left braket i right braket.x++;
//You always need to check a function which has your bullet advantages in it. Like what should be done if it hits a wall, or it ritches it's destination. This function should be for all of the bullets that this loop goes through. And it should be called likethis:
//We assoom that function named bcheck so it will be bcheck(i);
}
}
to spawn your bullet, Wheather you write a function or you write it in another block of code, That bcheck function should be called another time, To check what is in that bullet's range, like this: bcheck(bullets.length()-1)

You can also visit darkflier.com and download the sourcecode of zombie erina, It has a bullet class like this one I mentioned above.
Hope this helps.

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988