I cant finish Drop the Flag and i am going to quit playing because i am not moving forward in the game.
Post some code and ask for guidance. This game is about learning. Not trying on your own then giving up because it’s too hard. There’s a lot of very smart folks here willing to help you.
Explain what is happening and why you think it’s not working the way you want it, etc
loop:
flag = self.findFlag()
if flag:
# How do we get fx and fy from the flag's pos?
# (Look below at how to get x and y from items.)
self.pickUpFlag(flag)
else:
item = self.findNearestItem()
if item:
itemPos = item.pos
itemX = itemPos.x
itemY = itemPos.y
self.moveXY(itemX, itemY)
self.buildXY('fire-trap', 30, 31)
self.moveXY(18, 33)
self.buildXY('fire-trap', 30, 45)
self.moveXY(18, 33)
self.buildXY('fire-trap', 30, 16)
self.moveXY(18, 33)
This is my code so far.
I guess its just that the character is not fast enough to place down the fire trap and get everywhere.
and once I did defeat all the ogres, but i didn’t have enough time to collect the coins.
It isn’t that you aren’t fast enough. What you are supposed to do conceptually on this level is to use the flags to tell your hero when/where to build a fire trap. Right now it looks like you aren’t really using the flag and are just building a fire trap on each x after each coin.
Yaur is correct. The intention of the level is to use your flags to plant fire traps, and your character (between the times you’ve manually had it plant a fire trap with a flag) will be automatically collecting coins.
And all levels are made to be able to be solved by warriors which are the usually the slowest so it is always possible to pase
The problem is that you aren’t really doing anything with the flags. You just pick up a flag if it is placed, otherwise you move to the nearest item, then build traps in each spot.
Instead, when you find a flag, go place a firetrap there.
loop:
flag = self.findFlag()
if flag:
# How do we get fx and fy from the flag's pos?
# (Look below at how to get x and y from items.)
flagpos = flag.pos
flagX = flagpos.x
flagY = flagpos.y
self.buildXY('fire-trap',flagX,flagY)
self.pickUpFlag(flag)
else:
item = self.findNearestItem()
if item:
itemPos = item.pos
itemX = itemPos.x
itemY = itemPos.y
self.moveXY(itemX, itemY)
That will do better. Just only place a flag when you are wanting to place a fire trap there.
Also, notice how I formatted your last message to display code properly. (If you edit the post you can see that I added three ` marks before and after the code so that it would look pretty)
Okay thank you for the help I appreciate it. =)
// You need nothing, but some variables and stuff.
loop{
var flag = this.findFlag();
var item = this.findNearestEnemy();
if(flag) {
var fx = flag.pos.x;
var fy = flag.pos.y;
// How do we get the fx fy from the flag's pos?
this.buildXY("fire-trap" flag.pos.x, flag.pos.y);
this.pickUpFlag(flag);
}
else if(item) {
var itemPos = item.pos;
var itemX = item.pos.x;
var itemY = item.pos.y;
this.moveXY(itemX, itemY);
}
}
(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)
You must place the flag where you want to build traps. If theres not a flag, pick up the coins if there are coins. Don’t just use static code.
I think after over 1 month of inactivity you can expect a topic to be finished. You do not have to resurrect it from the dead.
I still have this issue: my code is:
loop{
var flag = this.findFlag();
var item = this.findNearestItem();
if(flag) {
this.buildXY(“fire-trap”, flag.pos.x, flag.pos.y); // This line Error, expected an identifier
this.pickUpFlag(flag);
}
else if(item) {
var itemPos = item.pos;
var itemX = item.pos.x;
var itemY = item.pos.y;
this.moveXY(itemX, itemY);
}
}
Please read the FAQ on how to properly format your code
3 posts were split to a new topic: “Item is null” despite if(item)