1

I'm not gonna be apologizing for using bgt heh, although I'm supposed to get around to learning something else. But after not having used it for years I figured I'd rewrite one of my favourite games - super deecout.
I could've used simpler code but I wanted the function to be reusable.
Anyway this throws up an error I can't seem to solve. I don't remember how to work with handles it seems.
class coin
{
double x;
double y;
coin()
{
}
}
[email protected][] generate_coinmap(int coin_counter, int map_size)
{
[email protected][] coinrun;
  coinrun.resize(coin_counter);
int tempy;
int tempx;
for(int counter=0; counter <coinrun.length()-1; counter++)
{
coinrun[counter].y=random(1, map_size);
coinrun[counter].x=random(1, map_size);
tempy=coinrun[counter].y;
tempx=coinrun[counter].x;
for(int counter2=0; counter2<=counter; counter2++)
{
if((coinrun[counter2].y==tempy)&&(coinrun[counter2].x==tempx))
{
counter--;
break;
}
}
}
return coinrun;
}
// this next part was just to test the coin list generator but is incomplete because of the runtime errors.
void main()
{
file lol;
[email protected][] feck;
feck=generate_coinmap(20, 20);
string hunt;
lol.open("output.txt", "w");
for(int heh=0; heh<feck.length()-1; heh++)
{
hunt+""+feck[heh].y+", "+feck[heh].x+"\r\n";
}
}

A read worth reading regarding this very forum:
https://blog.blackscreengaming.com/ag-f … 0/15/2018/

Thumbs up

2

what are the errors that you are getting?
and why did you open the file, if you aren't writing nothing to it?
you could do this though.
lol.open("output.txt", "w");
for(int heh=0; heh<feck.length()-1; heh++)
{
lol.write(hunt+""+feck[heh].y+", "+feck[heh].x+"\r\n");
lol.close();
}
}

If you want to get in touch with me you can follow me on Twitter
have a nice day.
Paul

Thumbs up

3

I would guess that coinrun starts out with the array full of nulls, rather than creating all the coins and their handles when you resize it, so you need to create coins before you try to modify them. So at the top of the for loop that sets the properties of the coins, you'd need two lines:
coin temp;
@coinrun[counter]=temp;
HTH

Some of my games
Keep up to date by following @Jeqofire on twitter!
Ear Ninja?

Thumbs up

4

Hi.

@jotes I wanted to be more clean with the code as I wasn't sure how the file ... well I knew you could do that, it just seemed messy to me.

@Cae_Jones thanks, I'll try that. I actually attempted something similar but mine was inefficient and caused compilation errors tongue

A read worth reading regarding this very forum:
https://blog.blackscreengaming.com/ag-f … 0/15/2018/

Thumbs up