I have spent about an hour on the level Drop The Flag. I find it a bit difficult to solve. I am going to paste my code and point out what i am finding hard to code.
loop: greenFlag = self.findFlag("green") blackFlag = self.findFlag("black") violetFlag = self.findFlag("violet") if greenFlag: self.findFlag("green") fx = 30 fy = 31 self.buildXY("fire-trap", fx, fy) self.moveXY(19, 34) if blackFlag: self.findFlag("black") fx = 29 fy = 46 self.buildXY("fire-trap", fx, fy) self.moveXY(19, 34) if violetFlag: self.findFlag("violet") fx = 30 fy = 16 self.buildXY("fire-trap", fx, fy) self.moveXY(19, 34) else: item = self.findNearestItem() if item: pos = item.pos itemX = pos.x itemY = pos.y self.moveXY(itemX, itemY)
So that is my code. I think i put wayyy too much because when i look at other articles i just see about 10 lines of code? My basic idea was to introduce each of the flags first and then state the action that will happen when i place each flag. I put the Black flag for the top part of the map, the Green flag for the middle part, and the Violet flag for the bottom part. I introduced what fx and fy means to say where i want the fire-trap to be placed and then i put to be moved to the coordinates (19, 34). I put the coordinates because i was trying to put to self.pickUpFlag("____") option in order to pick up the flag. It didn’t work though OR i was just confused at what it was telling me. The point is that when i put that code it told me “Pass a flag object to pick up.” I did not understand what that meant so i just ignored it and deleted that self.pickUpFlag("__") code.
I really need help on this level am i doing it right or i am doing too much code?