Skip to content

Commit

Permalink
Phoenix Game Engine 0.02
Browse files Browse the repository at this point in the history
  • Loading branch information
antim0118 committed Dec 7, 2024
1 parent c08a38b commit 1ea7cbb
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ Benchmark for PSP based on [Pixijs's BunnyMark](https://www.goodboydigital.com/p
| PSP | 60 FPS | 44 FPS | 22-23 FPS | 9 FPS | 4 FPS |
| PPSSPP (Emulator) | 60 FPS | 60 FPS | 46 FPS | 18 FPS | 9 FPS |

### [Phoenix Game Engine 0.02](https://archive.org/details/pgelua.7z)
| ![ICON0](https://raw.githubusercontent.com/antim0118/bunnyMark-psp/master/bunnyMarkPhoenixGameEngine/ICON0.png "ICON0") | 100 BUNNIES | 500 BUNNIES | 1000 BUNNIES | 2500 BUNNIES | 5000 BUNNIES |
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |
| PSP | 60 FPS | 30 FPS | 20 FPS | 9 FPS | 4-5 FPS |
| PPSSPP (Emulator) | 60 FPS | 60 FPS | 30 FPS | 12 FPS | 7 FPS |

### [LuaPlayerYT v0.4](https://vk.com/nomoreyuliateam)
| ![ICON0](https://raw.githubusercontent.com/antim0118/bunnyMark-psp/master/bunnyMarkLuaPlayerYTv04/ICON0.png "ICON0") | 100 BUNNIES | 500 BUNNIES | 1000 BUNNIES | 2500 BUNNIES | 3700 BUNNIES* |
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |
Expand Down
Binary file not shown.
54 changes: 54 additions & 0 deletions bunnyMarkPhoenixGameEngine/Assets/Scripts/Bunny.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Bunny = {}
Bunny.__index = Bunny

local random = math.random

function Bunny:create(texture)
local r = {}
setmetatable(r, Bunny)
r.x = 0
r.y = 0

r.texture = texture
r.speedX = random() * 10
r.speedY = random() * 10 - 5

r.scale = 0.5 + random() * 0.5
r.w = r.scale * texture.w
r.h = r.scale * texture.h

return r
end

function Bunny:processPhysics(bunny)
local x = bunny.x + bunny.speedX
local y = bunny.y + bunny.speedY
local speedX = bunny.speedX
local speedY = bunny.speedY + gravity
local w = bunny.w
local h = bunny.h

if x > maxX - w then
speedX = speedX * -1
x = maxX - w
elseif x < minX then
speedX = speedX * -1
x = minX
end

if y > maxY - h then
speedY = speedY * -0.85
y = maxY - h
if random() > 0.5 then
speedY = speedY - random() * 6
end
elseif y < minY then
speedY = 0
y = minY
end

bunny.x = x
bunny.y = y
bunny.speedX = speedX
bunny.speedY = speedY
end
119 changes: 119 additions & 0 deletions bunnyMarkPhoenixGameEngine/Assets/Scripts/Main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
require("Assets/Scripts/Rect")
require("Assets/Scripts/Bunny")
require('Assets/Scripts/buttonsCommon')

width = 480
height = 272

wabbitTexture = nil

bunnys = {}
gravity = 0.5 --1.5

maxX = width
minX = 0
maxY = height
minY = 0

startBunnyCount = 2
isAdding = false
count = 0

amount = 10

bgColor = pge.gfx.createcolor(255, 255, 255)
font = pge.font.load("Assets/Fonts/arialbd.ttf", 12, PGE_VRAM)

fontFGColor = pge.gfx.createcolor(0, 255, 255)
fontBGColor = pge.gfx.createcolor(16, 92, 182)

bunnyTextures = nil
currentTexture = nil
bunnyType = nil

function spawnBunny()
local bunny = Bunny:create(currentTexture)
table.insert(bunnys, bunny)
count = count + 1
end

function onReady()
wabbitTexture = pge.texture.load("Assets/Sprites/bunnys.png", PGE_VRAM)

bunnyTextures = {
Rect:create(2, 47, 26, 37),
Rect:create(2, 86, 26, 37),
Rect:create(2, 125, 26, 37),
Rect:create(2, 164, 26, 37),
Rect:create(2, 2, 26, 37)
}

bunnyType = 2
currentTexture = bunnyTextures[bunnyType]

for i = 1, startBunnyCount do
spawnBunny()
end
end


function onTouchStart()
isAdding = true;
end

function onTouchEnd()
bunnyType = bunnyType + 1
bunnyType = (bunnyType % 5) + 1;
currentTexture = bunnyTextures[bunnyType];

isAdding = false;
end



local fpsTimer = pge.timer.create()
local FPS = 60

onReady()
while true do
pge.controls.update()
pge.gfx.startdrawing()
pge.gfx.clearscreen(bgColor)

if pge.controls.pressed(PGE_CTRL_CROSS) then
onTouchStart()
end
if pge.controls.released(PGE_CTRL_CROSS) then
onTouchEnd()
end

if isAdding then
-- add 10 at a time :)
if count < 200000 then
for i = 0, amount do
spawnBunny()
end
end
end

wabbitTexture:activate()
for i = 1, count do
local bunny = bunnys[i]
Bunny:processPhysics(bunny)
local tex = bunny.texture
wabbitTexture:draw(
bunny.x, bunny.y, bunny.w, bunny.h,
tex.x, tex.y, tex.w, tex.h)
end

pge.timer.update(fpsTimer)
FPS = math.floor(1 / pge.timer.getdelta(fpsTimer))

pge.gfx.drawrect(0, 0, 90, 30, fontBGColor)
font:activate()
font:print(2, 2, fontFGColor, FPS .. " FPS")--, fontFGColor, fontBGColor)
font:print(2, 16, fontFGColor, count .. " BUNNIES")--, fontFGColor, fontBGColor)

pge.gfx.enddrawing()
pge.gfx.swapbuffers()
end
12 changes: 12 additions & 0 deletions bunnyMarkPhoenixGameEngine/Assets/Scripts/Rect.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Rect = {}
Rect.__index = Rect

function Rect:create(x,y,w,h)
local r = {}
setmetatable(r, Rect)
r.x = x
r.y = y
r.w = w
r.h = h
return r
end
11 changes: 11 additions & 0 deletions bunnyMarkPhoenixGameEngine/Assets/Scripts/buttonsCommon.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function press(button)
return buttons.pressed(buttons[button])
end

function held(button)
return buttons.held(buttons[button])
end

function release(button)
return buttons.released(buttons[button])
end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bunnyMarkPhoenixGameEngine/EBOOT.PBP
Binary file not shown.
Binary file added bunnyMarkPhoenixGameEngine/ICON0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bunnyMarkPhoenixGameEngine/ICON0.psd
Binary file not shown.
1 change: 1 addition & 0 deletions bunnyMarkPhoenixGameEngine/script.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dofile("Assets/Scripts/Main.lua")

0 comments on commit 1ea7cbb

Please sign in to comment.