Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


CRDR - Object Bouncing Logic in Cheat Engine Lua

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater
Reputation: 27

Joined: 10 Apr 2015
Posts: 983

PostPosted: Tue Jul 02, 2019 9:57 pm    Post subject: CRDR - Object Bouncing Logic in Cheat Engine Lua Reply with quote

Hi there,

Do you know the old arcade game called Arkanoid or Wall Break Out ?.
On those games, they using bounce logic to bouncing an object inside a client area.
So, here is the logic used for bouncing an object written in Cheat Engine Lua script.

Note:
1. Click on label object to start bouncing
2. Double click on the form to stop bouncing
3, Try to resize the form to get a bouncing effect (conclusion: object bouncing follows to form size)

Code:
frm=createForm()
frm.Position='poScreenCenter'
frm.BorderStyle="bsSizeable"
lbbounce=createLabel(frm)
lbbounce.Caption ='Cheat Engine'
lbbounce.Font.Size=20
lbbounce.Left=math.floor(frm.Width - lbbounce.Width)/2
lbbounce.Top=math.floor(frm.Height - lbbounce.Height)/2

local objWidth
local objHeight=50
local objX,objY,volX,volY

function bounced()
 volX=math.random(1,4)
 volY=math.random(1,4)
 objX=lbbounce.Left
 objY=lbbounce.Top
 objWidth=lbbounce.Width
 objX=math.random(0,frm.Width-objWidth)
 objX=math.random(0,frm.Height-objHeight)
 frm.DoubleBuffer=true
 timer1.Enabled=true
end

function timer1_Tick(sender)
 lbbounce.Left=objX
 lbbounce.Top=objY
 objX=objX+volX
 if (objX<0) then
 volX=-volX
 lbbounce.Font.Color=math.random(255,255)
 elseif (objX+objWidth>frm.Width) then
 volX=-volX
 lbbounce.Font.Color=math.random(0,255)
 end
 objY=objY+volY
 if (objY<0) then
 volY=-volY
 lbbounce.Font.Color=math.random(0,255)
 elseif (objY+objHeight>frm.Height) then
 volY=-volY
 lbbounce.Font.Color=math.random(0,255)
 end
end

timer1=createTimer(frm)
timer1.Interval=24
timer1.Enabled=false
timer1.onTimer=timer1_Tick

function stopit()
 timer1.Enabled=false
 lbbounce.Left=math.floor(frm.Width - lbbounce.Width)/2
 lbbounce.Top=math.floor(frm.Height - lbbounce.Height)/2
end

function exiter()
 timer1.Enabled=false
 timer1.Destroy()
 closeCE()
 return caFree
end

frm.show()
lbbounce.onClick=bounced
frm.onDblClick=stopit
frm.onClose=exiter


Your challenge:
- Try change TEXT with an Image
- Make better GUI
- Medium Level: Try to make an Arkanoid Game

Demo Video: https://youtu.be/30vgBZ4UJ0Y

Enjoy...

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites