Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 school project
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Notthebbq




PostPosted: Thu Mar 31, 2011 11:50 am   Post subject: school project

hi, my group has a semester long project to make a game in python. were doing a TD and i wanted to know if you could tell us anyway to make creeps go along any created path like normal internet TD like desktop where the creeps will seek out a new path or go around towers you place down
Sponsor
Sponsor
Sponsor
sponsor
apython1992




PostPosted: Thu Mar 31, 2011 12:23 pm   Post subject: RE:school project

Typically path collision detection involves using a color key; you can tell if an object is on the path by finding out the color of the pixels beneath it. Here is a good tutorial on this: http://www.xnadevelopment.com/tutorials/theroadnottaken/theroadnottaken.shtml . The tutorial was written for XNA game developers (C#), but you should be able to grab the concepts out of it and translate to Python. Are you using Pygame?
Tony




PostPosted: Thu Mar 31, 2011 12:40 pm   Post subject: Re: RE:school project

apython1992 @ Thu Mar 31, 2011 12:23 pm wrote:
Typically...

It is not, as using the same buffer for both collision information and graphics is bad news. It either forces simple and _very_ restricted animations, or opens up the possibility of bugs where a collision is not detected when a bullet animation just happened to fly over a tower at the right frame.

A much better idea is to just have an array/grid/tile-map.

Pathfinding itself could use something like A* http://en.wikipedia.org/wiki/A*_search_algorithm
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
apython1992




PostPosted: Thu Mar 31, 2011 1:16 pm   Post subject: RE:school project

Well, as far as I understand it, the color key information for the path would be on a separate back buffer. And yeah, typically is probably not true, it's just the only way I've heard it done Smile OP: Take Tony's advice over mine, using tile-based paths is probably a much better option.
Insectoid




PostPosted: Thu Mar 31, 2011 4:32 pm   Post subject: RE:school project

In a tower-defense game you really don't need pathfinding unless you want to make a level creator or something. You can easily create a list of waypoints that the creeps travel to. Once you have that, it's as easy as moving toward awaypoint.

If you simply must use AI pathfinding, you can use color detection as mentioned above. Just draw your black/white (or w/e) map to the buffer, do your checks, then re-draw your detailed map to the buffer before outputting it to the screen (I dunno if you can manually double-buffer and update in Python; it's quite trivial in Turing but I've never done graphics in anything else).
Notthebbq




PostPosted: Fri Apr 01, 2011 11:23 am   Post subject: Re: school project

apython1992, yes we are using pygame to make this
apython1992




PostPosted: Fri Apr 01, 2011 11:32 am   Post subject: RE:school project

Cool. Do you understand Tony's method? This would be the simplest way to represent a path, I would think.
Notthebbq




PostPosted: Mon Apr 04, 2011 1:13 pm   Post subject: Re: school project

yes we understand Tony, our original plan was to use premade maps and just use, mind blank, point movement. like left to right A -- B and top to bottom B -- C. i was just looking to see how you can do an open map path movement.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: