[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Pygame Problem Solving 1
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Pygame Problem Solving 1
- From: "Lamonte Harris" <pyth0nc0d3r@xxxxxxxxx>
- Date: Wed, 12 Sep 2007 23:11:00 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Thu, 13 Sep 2007 00:11:14 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=hMe96KKONzbwbgM1O5PWvZTI+zFRgFVG60pAFMSI1mI=; b=c1+SqNoTsZY528g5foAYV70ud+Uw6FZ39WghX32+lmPG0AuCidbAYTaX8NOam7AkWgXfpXGrySblB+ewgURgrmb+U6mkQyBfWJJNOQ/5P1iCKoeB17ZY/Sv/CL2ODZRql2O956dQOzhrFkqth2vFoiw3GucL4lyIJO+Gf7W8D08=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=eLsVav/FLtYctRDxBF9OO9ou+FQ++uABGJoAFrMgh4rbE9/qswuNx896xKQzzTDIBEJbWyazgtIbNM3PpkFnGfEZlgdqwPcyYTLGxH8ndkjuaHQ7nIhJwgFBhMfIsQgmZCHXheqM63rM3unYuzdBZzK2fWmE+KnlU9/UFP8FAa0=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Problem Solving 1
--------
Rendering a map switching script. There will be a simple window. At the bottom if tge screen it will say pick a map. Using the mouse events and positioning I will be able to click on the squares that will represent certain maps at the bottom of the screen and the different maps will be displayed.
How to do that?
---
First make my "genmap" class then in the __init__ function add 2 variables "self.cmap" and "self.blockrect". "self.cmap" would represent the current map to be displayed. If there isn't a variable assigned then the area above the boxes will not be displayed. Make a function to display the tile maps. With that function I would append square rects to te "
self.blockrect" variable for later use to detect if the current mouse position will match any of the rects when I left mouse click on the pygame window. In that list, there could be tuples inside the list for instance:
self.blockrect = [((0,0,0,0),1)]
The first value in the tuple would be the map rect second value in the tuple would represent the map name in the directory to load.
How would I get the current top surface of where my mouse is located?
Just giving a guess, I was thinking of making a square surface thats the same size of the sqaures at the bottom of the screen but the sqaures at the bottom of the screen have different possitioning meaning its easier to located different maps. Like example:
Pygame Window:
----------------------------------------
| ___ |
| |--\_/--| /-\ |___| |
| |_/\/\_| /---\| |
| |
| |
| |
--------------------------------------
| ------ ------ ------ |
| | | | | | | |
| ------ ------ ------ |
--------------------------------------
Thats above is the whole window its all one big part but sort of seperated if you get what I mean. Probably by a pygame line.
So I was thinking if I made an invisible rect that moved when the mouse moved then I left clicked and it would get the current surface position of the rect, then it would run a function to see if that current position matches any of the map squares at the bottom of the screen then the "
self.cmap" variable would update.
Does anyone think my theory will work, I've only written then down at school and is attempting to do this this weekend for some more learning with pygame.
Thanks for the read Lamonte.