[Tutorial] Python PSP Programming
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Forum rule Nº 15 is strictly enforced in this subforum.
Re: [Tutorial] Python PSP Programming
sorry, was confused, image 2 ist the background and image 1 is half transparent
Advertising
-
- Guru
- Posts: 2874
- Joined: Sat Apr 21, 2012 1:23 pm
- Location: The North Pole
Re: [Tutorial] Python PSP Programming
Code: Select all
while True:
screen.clear(CLEAR_COLOR)
screen.blit(image2)
screen.blit(image1, blend = True)
screen.swap()
Advertising
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
Re: [Tutorial] Python PSP Programming
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:
hope you can help me again
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()
-
- Retired Mod
- Posts: 3100
- Joined: Tue May 01, 2012 11:32 am
- Location: Behind you!
Re: [Tutorial] Python PSP Programming
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:
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
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)
Re: [Tutorial] Python PSP Programming
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?
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
Thanks for the tutorial is just what I was looking for
-
- Posts: 78
- Joined: Fri Oct 19, 2012 7:24 am
- Location: :: anywhere ::
Re: [Tutorial] Python PSP Programming
You can run those files with pyGames Its make us more fun. .
@Exploit hunting are my favourite activities since I got my first Phat PSP
http://lolpsvhex.blogspot.com/
http://lolpsvhex.blogspot.com/
Re: [Tutorial] Python PSP Programming
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?
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?
"If the truth is a cruel mistress, then a lie must be a nice girl"
-
- Retired Mod
- Posts: 3100
- Joined: Tue May 01, 2012 11:32 am
- Location: Behind you!
Re: [Tutorial] Python PSP Programming
yeah I answered that question in a PM
Re: [Tutorial] Python PSP Programming
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:
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)
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
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)