[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Mode 7 Demo
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Mode 7 Demo
- From: bhaaluu <bhaaluu@xxxxxxxxx>
- Date: Sat, 26 Jan 2008 14:35:54 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 26 Jan 2008 14:36:08 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=kJVPnjr2hlodDTE1Xg/RqEbx3ZyDf2J6Xke4QkxwUdY=; b=dvgCxIOI6yPX7IAmg0Rh6LTXkyZ8mDlwhMbA1LFCgodeZKJbcJghvQTcvqgp5QnJfA0uuPDRSefyZ0BsnvphjPSknRjSH3HZPZJ0nEFMwdwJc2DnEYdF5RD+qq12wWnZjMAHv74OGmmoR/sI4mkGb89F8jF9PKymaSBxHUnG+x8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=fJCQo0/ZvvSgScLgXceW6WD8T8c58wUhBOPjD7yIOqCBszMBDUmshklJVViabsKacLkYJi4dPdLZBzafVXJw5LrvzOLsJ6rXZ0VngvmAZi/Gn5WxvNtcU8YOidufj8rqT/owTk+/IWTGG2+EmLYnsq/5qgzEXju86gzgpoyGGFA=
- In-reply-to: <479B6483.10400@xxxxxxxxxx>
- References: <479B6483.10400@xxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Do you have a link to landscape.bmp and sky.png?
Traceback (most recent call last):
File "mode7.py", line 9, in ?
ground = pygame.image.load("landscape.bmp") ## 1000x1000 works
pygame.error: Couldn't open landscape.bmp
Traceback (most recent call last):
File "mode7.py", line 10, in ?
sky = pygame.image.load("sky.png") ## At least 800x300
pygame.error: Couldn't open sky.png
I converted the landscape.jpg to landscape.bmp to get the second Traceback.
This looks nice!
Arigato!
--
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance. Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
On Jan 26, 2008 11:49 AM, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
> I put together a quick-and-dirty demo of a "Mode 7" pseudo-3D effect. I
> have no specific plans for it, but it looks neat. The framerate is bad.
> Thoughts?
>
> Screenshot at <http://kschnee.xepher.net/pics/080126_mode7.jpg>.
> Example of the effect in "Secret of Mana":
> <http://mmxz.zophar.net/rpg/mana2/images/flammie.gif>
>
> Kris
>
> """
> Quick demo of a "Mode 7" pseudo-3D effect,
> as seen in some 16-bit-era video games.
> """
>
> import pygame
> screen = pygame.display.set_mode((800,600))
>
> ground = pygame.image.load("landscape.bmp") ## 1000x1000 works
> sky = pygame.image.load("sky.png") ## At least 800x300
>
> ## Fog @ horizon.
> fog = pygame.surface.Surface((800,20)).convert_alpha()
> for y in range(20):
> a = 200 - (10*y)
> pygame.draw.rect(fog,(255,255,255,a),(0,y,800,5))
>
> class Mode7:
> def __init__(self,**options):
> self.sky = options.get("sky")
> self.ground = options.get("ground")
> self.fog = options.get("fog")
> ## "Location" of the top-left part we'll draw.
> self.ground_x, self.ground_y = options.get("coords",(0,0))
> self.movement = options.get("movement",(3,3))
>
> def Draw(self):
> stretch_factor = 200.0 ## Try eg. 75.0 also
> for y in range(300,600):
> ## Take a line from the original & stretch it.
> img_y = (y+self.ground_y-300) * 2
> line = pygame.surface.Surface((800,1))
> line.blit(self.ground,(0,0),(self.ground_x,img_y,800,1))
> w = 800 * (1.0 + ((y-300)/stretch_factor) )
> x = -(w-800)/2 ## Draw wide line left of screen's edge
> line = pygame.transform.scale(line,(w,1))
> screen.blit(line,(x,y))
> screen.blit(self.sky,(0,0),(200,0,800,300))
> screen.blit(self.fog,(0,300))
>
> def Go(self):
> for n in range(40):
> ## screen.fill((0,0,0)) ## Not needed; screen is filled
> self.Draw()
> pygame.display.update()
> self.ground_x += self.movement[0]
> self.ground_y += self.movement[1]
>
>
> m7 = Mode7(sky=sky,ground=ground,fog=fog)
> m7.Go()
>
>