simple animation

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
paulieweb
Posts: 8
Joined: Thu Nov 03, 2005 10:18 am
Location: PSU
Contact:

simple animation

Post by paulieweb »

sorry to ask a rudimentary question, but i am relatively new to graphics

if i wanted to fill a cylinder type object up one line of pixels at a time:

_
| |
| |
| |
| |
_

(imagine each row is 4 pixels wide or something)
what is the best way to do this?

just make a for loop to drawline one at a time?
User avatar
JoshDB
Posts: 87
Joined: Wed Oct 05, 2005 3:54 am

Post by JoshDB »

Here's something that might help. Sorry for the lack of proper explanation, but this code basically eases a menu up, so it goes faster then gradually slows down.

Code: Select all

function ConceptCreate:CloseMenu()
	menuopenfull = false
	while menuposy < 273 do
		screen&#58;clear&#40;&#41;
		Concept&#58;Render&#40;&#41;
		Concept&#58;Menu&#40;&#41;
		screen.waitVblankStart&#40;1&#41;
		screen.flip&#40;&#41;
		if menuposy < 273 then
			menuposy = menuposy + 1
			if menuposy < 260 then
				menuposy = menuposy + 2
				if menuposy < 250 then
					menuposy = menuposy + 3
					if menuposy < 240 then
						menuposy = menuposy + 4
						if menuposy < 230 then
							menuposy = menuposy + 5
							if menuposy < 220 then
								menuposy = menuposy + 6
							end
						end
					end
				end
			end
		end
	end
	screen&#58;clear&#40;&#41;
	Concept&#58;Render&#40;&#41;
	menuposy = menuposy + 1
	screen.waitVblankStart&#40;1&#41;
	screen.flip&#40;&#41;
end

function ConceptCreate&#58;Render&#40;&#41;
	Concept&#58;RenderBaseImages&#40;&#41;
	
	if menuopenfull == true then
		Concept&#58;Menu&#40;&#41;
	end
end

function ConceptCreate&#58;RenderBaseImages&#40;&#41;
	screen&#58;blit&#40;0,0,bg&#41;
end

function ConceptCreate&#58;Menu&#40;&#41;
	screen&#58;blit&#40;menu_viewimagesposx,menuposy + 10,menu_viewimages&#41;
	screen&#58;blit&#40;menu_viewmusicposx,menuposy + 20,menu_viewmusic&#41;
	screen&#58;blit&#40;menu_viewprogramsposx,menuposy + 30,menu_viewprograms&#41;
	screen&#58;blit&#40;menu_explorerposx,menuposy + 40,menu_explorer&#41;
	screen&#58;blit&#40;menu_systeminfoposx,menuposy + 50,menu_systeminfo&#41;
	screen&#58;blit&#40;menu_utilitiesposx,menuposy + 70,menu_utilities&#41;
	screen&#58;blit&#40;menu_closeposx,menuposy + 90,menu_close&#41;
end
From Concept - The Zulu Version PSP Shell

Might be a little complex for what you want, but yes, if you don't use this, you could use a drawline loop (;
chaos
Posts: 135
Joined: Sun Apr 10, 2005 5:05 pm

Post by chaos »

simplest way would be a for loop with a 4 pixel wide rectangle (instead of 4 lines).
Chaosmachine Studios: High Quality Homebrew.
paulieweb
Posts: 8
Joined: Thu Nov 03, 2005 10:18 am
Location: PSU
Contact:

Post by paulieweb »

not really in relation to the preceeding, but i didn't feel like starting a new thread

if i have something like this:

Code: Select all

			if marked&#91;i&#93;&#91;j&#93; == 1 then
				strpiece = hor
			end

			if marked&#91;i&#93;&#91;j&#93; == 2 then
				strpiece = vert
			end

			if marked&#91;i&#93;&#91;j&#93; == 3 then
				strpiece = tjunct
			end

			if marked&#91;i&#93;&#91;j&#93; == 4 then
				strpiece = ld
			end

			if marked&#91;i&#93;&#91;j&#93; == 5 then
				strpiece = lu
			end

			if marked&#91;i&#93;&#91;j&#93; == 6 then
				strpiece = rd
			end

			if marked&#91;i&#93;&#91;j&#93; == 7 then
				strpiece = ru
			end
		end
	end

	screen&#58;blit&#40; 16 * &#40;i - 1&#41; + 236, 16 * &#40;j - 1&#41; + 28, strpiece&#41;
it gives me an error because strpiece isn't a picture. how would i go about assigning the picture names (tjunct, ru, vert, etc) to a variable that lua would output when i do the bottom line, screen:blit ?
User avatar
JoshDB
Posts: 87
Joined: Wed Oct 05, 2005 3:54 am

Post by JoshDB »

This is a problem I've hit. I fixed it with

Code: Select all

if strpiece == ru then
       code
end
Post Reply