Page 3 of 6
Re: [Tutorial] Python PSP Programming
Posted: Mon Sep 24, 2012 5:29 am
by blacky94
sorry, was confused, image 2 ist the background and image 1 is half transparent
Re: [Tutorial] Python PSP Programming
Posted: Mon Sep 24, 2012 5:48 am
by qwikrazor87
Code: Select all
while True:
screen.clear(CLEAR_COLOR)
screen.blit(image2)
screen.blit(image1, blend = True)
screen.swap()
Try that.
Re: [Tutorial] Python PSP Programming
Posted: Tue Sep 25, 2012 5:59 pm
by blacky94
Hi,
i have again a problem with python. I want to blit a image on a surface, the image have the size 480x272. It works fine when i blit it with the parameter sx = 0, sy = 0, w = 480, h = 272, dx = 0, dy = 0, dw = 480, dh = 272.
But when I press the left button the image should change the position
press left x = x - 16
parameter -> sx = 0 - x, sy = 0, w = 480, h = 272, dx = 0, dy = 0, dw = 480, dh = 272
But the sx position is now negative and i become the error:
ValueError: subsurface rectangle outside surface area
and when i press right the x variable should be x = x + 16, but it dont work, too. and i become the same error because the x+width position is now over 480. here is a sample:
Code: Select all
import pspnet
import psp2d
import pspos
screen = psp2d.Screen()
CLEAR_COLOR = psp2d.Color(255,255,255)
image = psp2d.Image("test.png") #size -> 480x272
x = 0
while True:
pad = psp2d.Controller()
if pad.left:
x += 16
if pad.right:
x -= 16
screen.clear(CLEAR_COLOR)
screen.blit(image,sx = x,sy = 0)
screen.swap()
hope you can help me again

Re: [Tutorial] Python PSP Programming
Posted: Tue Oct 02, 2012 7:56 pm
by Acid_Snake
try creating an empty image instance with more resolution and then blit the image into that empty image, then blit the empty image into the screen, something like this:
Code: Select all
empty_img = psp2d.Image(1000, 1000)
img = psp2d.Image(path_to_your_image)
scr = psp2d.Screen()
empty_img.blit(img)
scr.blit(empty_img)
please don't copy-paste this code, it will most likely not work, it's just to show you the idea, which you have to properly implement into your needs
Re: [Tutorial] Python PSP Programming
Posted: Thu Dec 27, 2012 10:35 pm
by Tonakai
Very interesting tutorial here. I'll definitelly be looking into this once I've got a better grasp on Python (looks like a chose a good language to learn).
One thing I'm wondering is whether following your "Python GUI" tutorials prior to this would give me an advantage?
Re: [Tutorial] Python PSP Programming
Posted: Fri Dec 28, 2012 8:23 pm
by ultear
Thanks for the tutorial is just what I was looking for

Re: [Tutorial] Python PSP Programming
Posted: Fri Dec 28, 2012 8:39 pm
by I'm Overfloooow
You can run those files with pyGames

Its make us more fun. .
Re: [Tutorial] Python PSP Programming
Posted: Sat Dec 29, 2012 4:46 am
by hgoel0974
dude Thanks for allowing me to add these to the wiki
I read them only so that I knew what I was putting on the Wiki and now I know that python is closer to C# than C++ so, I can make homebrew in python then!
Just a question though, suppose I want to launch other homebrew, how would I do it?
Re: [Tutorial] Python PSP Programming
Posted: Sun Dec 30, 2012 6:39 pm
by Acid_Snake
yeah I answered that question in a PM
Re: [Tutorial] Python PSP Programming
Posted: Tue Mar 05, 2013 11:30 am
by SifJar
Can anyone give me some pointers on running the code on PC? I have installed PyGame, and tried importing pygame as psp2d, but that didn't work (pygame has no Screen() function), so I'm not sure what I need to do. Or am I meant to import both pygame and psp2d (in which case, where do I get the psp2d module for PC)? Any advice would be great, would make it much easier to mess around with this rather than having to transfer py scripts back and forth between my PC and PSP for editing.
EDIT: Well I figured that out, needed to download this:
https://code.google.com/p/pspstacklessp ... p&can=2&q=
But I do have another question; what would be the correct way to exit a program? For example I have this script:
Code: Select all
#! /usr/bin/env python
import pygame, psp2d
scr = psp2d.Screen()
fnt = psp2d.Font("font.png")
img = psp2d.Image(480, 272)
img.clear(psp2d.Color(0,0,0))
fnt.drawText(img, 0, 0, "Hello World!")
fnt.drawText(img, 0, 20, "Press X to change the screen")
scr.blit(img)
scr.swap()
while True:
pad = psp2d.Controller()
if pad.cross:
img.clear(psp2d.Color(255,0,0))
fnt.drawText(img, 0, 0, "Now it's RED!")
fnt.drawText(img, 0, 20, "Triangle to quit, Circle to change again!")
scr.blit(img)
scr.swap()
while True:
pad = psp2d.Controller()
if pad.triangle: exit() #HERE
elif pad.circle:
img.clear(psp2d.Color(0,255,0))
fnt.drawText(img, 0, 0, "GREEN!")
fnt.drawText(img, 0, 20, "Square to exit now")
scr.blit(img)
scr.swap()
while True:
pad = psp2d.Controller()
if pad.square: exit() #HERE
which works great apart from exiting the program (the lines commented with "#HERE"), which crashes both then PSP and when it is run on the PC. Is there some better way to do this? If so, could someone please tell me it? I've tried looking at samples, but I can't seem to find what I'm looking for...
EDIT: Actually, this does work on PC. But not on the PSP. And obviously the PSP is the more important factor here (although ideally the solution would work on both)