Cheat Engine
The Official Site of Cheat Engine

Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1348

Posted: Tue Jul 02, 2019 12:55 am    Post subject: CRDR - CE Car Racing Game (math.random & bounds)

Hi, there. Interested with this topic:

https://forum.cheatengine.org/viewtopic.php?t=610317
https://forum.cheatengine.org/viewtopic.php?t=610419

This is my turn to proofing CE (Lua) logic about using math.random() and bound intersect with() function or collision detector function. I decided to translate one of my C# racing game projects to CE Lua scripting.

in C#, there is a default function to check boundaries/objects collision, example:

 Code: if (player.Bounds.IntersectsWith(AI1.Bounds) || player.Bounds.IntersectsWith(AI2.Bounds))             {                 gameOver();             }

Since Lua doesn't have bound. bounce and collision functions by default, then we need to make a custom function for those events.

Generally in Lua to detect intersect/collision we use:

 Code: -- Collision detection function; -- Returns true if two objects overlap, false if they don't; -- x1,y1 are the top-left coords of the first object, while w1,h1 are its width and height; -- x2,y2,w2 & h2 are the same, but for the second object. function CheckCollision(x1,y1,w1,h1, x2,y2,w2,h2)   return x1 < x2+w2 and          x2 < x1+w1 and          y1 < y2+h2 and          y2 < y1+h1 end

Anyway, there is another Lua collision detection function present by Lynxz Gaming a CEF member.

 Code: function onCollision(obj1,obj2)  obj1x = obj1.left  obj1y = obj1.top  obj1w = obj1.width  obj1h = obj1.height  obj2x = obj2.left  obj2y = obj2.top  obj2w = obj2.width  obj2h = obj2.height  if obj2x + obj2w >= obj1x and obj2y + obj2h >= obj1y and obj2y <= obj1y + obj1h and obj2x <= obj1x + obj1w then  return true  end end

Not much different, right?.

Next is how to implementing math.random(n,n), which I used this Lua function to set some images position on my car racing games so they appear on a random position trigger by a timer.

Here is the complete project:

Project Details
Project Name: CRDR-CE Racing Game
Release Date: 01-07-2019
Author/Creator: Corroder a.k.a VCL Bro

Requirement
CE 6.8.3
Lua 5.3

Project Resource
Contain:
- Images for the project
- BG Music
- Event Sound

NOTE:
Extract the resources folder using WinRar and place it at the same location as your project.
Give attention with folder name.

Add to CE Table File:

- hit.wav
- race.xm

Demo Video (C# project version able to download on video description)

https://youtu.be/NDNt6iLJHn8

Complete CE Lua script:

Term and Condition
Feel free to edit, use and share.
No hidden code / No encoded script = 100% free

1. Try to make better GUI with better music/background
2. Try to beat the game with getting Gold Medal (you need to finish the distance as 3500)

Enjoy...

CRDR Racing Game.JPG
Description:
Filesize:  43.01 KB
Viewed:  4199 Time(s)

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Aylin
Grandmaster Cheater
Reputation: 9

Joined: 16 Feb 2017
Posts: 592

Posted: Tue Jul 02, 2019 1:53 pm    Post subject:

This is unfair, @Corroder.
Your coding skills are better.
I think the next version,
Can be for different games.
Nice job, congratulations, man.

14.jpg
Description:
Filesize:  60.21 KB
Viewed:  4161 Time(s)

_________________
Hi Hitler Take control of your trainer
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1348

 Posted: Tue Jul 02, 2019 7:58 pm    Post subject: @Aylin..., No no, my coding skill just ordinary and I still learning for coding. Btw, Bronze medal with 1069 distance is not bad. However, be careful when driving or your driver's licence will be busted... hahaha _________________Stealing Code From Stolen Code... And Admit It.. Hmmm....Typically LOL
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 6 Hours Page 1 of 1

 Jump to: Select a forum Cheat Engine----------------Cheat EngineCheat Engine MacOSCheat Engine Lua ScriptingCheat Engine ExtensionsCheat Engine TutorialsGeneral GamehackingAuto Assembler tutorialsPointer tutorialsGame specific tutorialsWebbrowser stuff related tutorialsConsole ModdingLUA Tutorials General Discussions----------------General DiscussionsArtComputer TalkRandom spamArt RequestsArt TutorialsWillekeurige RotzooiGuestsHorse Excrement Cheat Requests----------------Single player cheat request Cheat Engine Downloads----------------TablesTrainersAuto Assemble scripts Coding----------------Cheat Engine SourceCETC Server and ClientsDBVMPlugin developmentGeneral programmingBinariesCrackmesGeneral programming+Game Development2D Graphics3D ModelingGameplay designWeb Development Games----------------Flash GamesGaia OnlineStick Arena Hello Kitty Forums----------------Temp
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