rotating a game board

This is the place for queries that don't fit in any of the other categories.

rotating a game board

Postby keelboat » Tue Apr 23, 2013 7:31 am

Hi guys,
This is more of a conceptual question:
If I want to animate the rotation of an entire playing board (a chess board with figures for example) by 90 degrees, am I better off rotating the individual fields of the board around its center point individually, or is there a way for me to take a 'screenshot' of the field and rotate that as a single picture? I would have the code rotate the actual values of the board separately from the animation (once the animation was done, I would just redraw the screen with everything now in the right positions).

I hope my question is understandable. I have just started programming a couple of days ago and have so far only done text based games, but want to move onto GUI based games,

thank you in advance, your help is very much appreciated,
keelboat
keelboat
 
Posts: 3
Joined: Tue Apr 23, 2013 7:29 am

Re: rotating a game board

Postby hansn » Tue Apr 23, 2013 10:38 am

I think it depends on your code and what library you are using (like pygame).

If every field is an object of its own, I would somehow connect every piece to a single point, and then by moving that single point the entire board would move/rotate.
But that's just me, there could be easier/better ways to do it.

Assuming you have not allready made a working, playable chess board, i would focus on that to begin with.
If you have made it allready, I would love to see it. I could also be of more help if I did.
hansn
 
Posts: 87
Joined: Thu Feb 21, 2013 8:46 pm

Re: rotating a game board

Postby metulburr » Tue Apr 23, 2013 11:28 am

it would depend of what library you are using, but sinse you are refering to a game i will estimate pygame then.

In pygame a simple method rotates a image, which essentially could be your board
http://www.pygame.org/docs/ref/transfor ... orm.rotate

I hope my question is understandable. I have just started programming a couple of days ago and have so far only done text based games, but want to move onto GUI based games,

I would suggust delving into just programming first. Dont rush it.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1312
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: rotating a game board

Postby hansn » Tue Apr 23, 2013 3:49 pm

There are books that teach python while learning to create games with pygame. Check out http://inventwithpython.com/, I have not read it but it has good ratings at amazon.
hansn
 
Posts: 87
Joined: Thu Feb 21, 2013 8:46 pm

Re: rotating a game board

Postby Mekire » Tue Apr 23, 2013 5:18 pm

I haven't read that book but I just glanced at a sample from it and the first thing I saw was:
Code: Select all
def main():
    global FPSCLOCK, DISPLAYSURF, BASICFONT, RESET_SURF, RESET_RECT, NEW_SURF, NEW_RECT, SOLVE_SURF, SOLVE_RECT
I would get that book as far away from anyone trying to learn python as possible.

I really do believe that people try to delve into making "games" far to quickly. I understand the need to feel like you are "creating something" as you learn, but you will do much better if you learn the basics soundly first (and yes this includes classes/OO). I have attempted to help people in the past with pygame who are just starting and want to make something like a platformer. Suffice to say they get out of their depth almost immediately. Everything in pygame (and most APIs for that matter) is based on classes. If you don't understand what classes are, what they are for, or how they work, you won't get anywhere. You will be cutting and pasting code because you have seen it before and not because you understand it.

-Mek

Edit: Looked at that book a little more. He does almost everything I tell people to never do in pygame. He collapses his namespace; he updates the display in multiple functions rather than in one place. He iterates through the event queue with a for loop in multiple places. Anyway enough ranting... my advice is to find something better.

Edit2: Just realized I was looking at the other book listed there. Not the one mentioned. So my above comments apply to "Making Games with Python and Pygame," not to "Invent Your Own Computer Games with Python". I will take a look at that one later. :P
User avatar
Mekire
 
Posts: 983
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: rotating a game board

Postby hansn » Tue Apr 23, 2013 6:39 pm

I'm a newbie myself and I totally agree with what Mekire says - learn what classes are and how they work. I did not at first, but when I did everything became clearer.
hansn
 
Posts: 87
Joined: Thu Feb 21, 2013 8:46 pm

Re: rotating a game board

Postby keelboat » Wed Apr 24, 2013 2:58 am

Hi Mek,
thanks for the advise,
I was actually following the two books that you were referring to, just wondering if you have any suggestions on how I can best teach myself about classes.

thanks for the help,
keelboat
keelboat
 
Posts: 3
Joined: Tue Apr 23, 2013 7:29 am

Re: rotating a game board

Postby keelboat » Wed Apr 24, 2013 3:03 am

hansn wrote:I think it depends on your code and what library you are using (like pygame).


If every field is an object of its own, I would somehow connect every piece to a single point, and then by moving that single point the entire board would move/rotate.
But that's just me, there could be easier/better ways to do it.

Assuming you have not allready made a working, playable chess board, i would focus on that to begin with.
If you have made it allready, I would love to see it. I could also be of more help if I did.


I was planning to use pygame and I like your Idea of connecting the pieces to a point. I will have to think about that some more.
I haven't made the board yet, I was just trying to figure out the conceptual method at this point. I also still have to work out some of the game 'rules'. I'll keep you updated on the progress if you want.

cheers,
Keelboat
keelboat
 
Posts: 3
Joined: Tue Apr 23, 2013 7:29 am


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests