Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: CinusMinus on July 20, 2014, 05:51:04 pm

Title: [Lua] Hill Climb Racing
Post by: CinusMinus on July 20, 2014, 05:51:04 pm
Me again with another lua game for the nspire.
This is the result of me playing around with the built-in physics engine in lua. In the current state the game is playable, but lacking important elements, such as score, upgrades, different cars and better graphics.
What is implemented right now:
- car controlled with the arrow keys
- generated landscape wich adds to the front and removes its back
- bad vehicle physics

Planned features include:
- proper vehicle physics
- highscores
- upgrades
- different cars
- different tracks
- fuel
- death which ends the game :devil:
(basically the stuff from Hill Climb Racing)

Screenshots:
(http://img.ourl.ca/hcr.jpg)

Title: Re: Hill Climb Racing
Post by: DJ Omnimaga on July 20, 2014, 08:53:56 pm
Looks quite cool. I can't try it though since I have OS 3.1 D:

Will it be like the bike game in California's Games? http://en.wikipedia.org/wiki/California_Games
Title: Re: Hill Climb Racing
Post by: CinusMinus on July 21, 2014, 07:31:55 am
Looks quite cool. I can't try it though since I have OS 3.1 D:
I would kepp downward compatibility, if the physics engine would be included in older versions. I'm sorry

Will it be like the bike game in California's Games? http://en.wikipedia.org/wiki/California_Games (http://en.wikipedia.org/wiki/California_Games)
Well at the moment I have no plans of how exactly the vehicles should look like. And I thought of this: https://play.google.com/store/apps/details?id=com.fingersoft.hillclimb (https://play.google.com/store/apps/details?id=com.fingersoft.hillclimb)
Title: Re: Hill Climb Racing
Post by: Princetonlion.tibd on July 21, 2014, 09:06:42 am
[...]
- bad vehicle physics

Wait, you're implementing bad vehicle physics?
Title: Re: Hill Climb Racing
Post by: DJ Omnimaga on July 21, 2014, 11:07:01 am
I think he means that for the time being he hasn't implemented good one yet. :P
Title: Re: Hill Climb Racing
Post by: CinusMinus on July 21, 2014, 12:00:38 pm
That's it :D
I'm still working out how joints and springs work, that's why the vehicle physics are not too god right now. But that will be one of the next things to do  ::)
Title: Re: Hill Climb Racing
Post by: LDStudios on July 22, 2014, 11:36:03 am
Haha, if your car gets stuck, just spawn like 50 cars under it to fling it forward :P
Anyways, great job!
Title: Re: Hill Climb Racing
Post by: Princetonlion.tibd on July 22, 2014, 11:37:00 am
I don't think you can spawn cars in game :P
Title: Re: Hill Climb Racing
Post by: LDStudios on July 22, 2014, 11:38:00 am
You can, I just tried it out :P
Probably just temporary for testing the physics
Title: Re: Hill Climb Racing
Post by: Princetonlion.tibd on July 22, 2014, 11:53:12 am
I suggest keep that feature.
It could overload your calc :)
Title: Re: Hill Climb Racing
Post by: CinusMinus on July 23, 2014, 04:37:05 pm
You can even spawn blue balls. But I won't tell you how  :P (and I'm not sure if it would work on a real calc insted of the emulator)
Anyway, this is just a temporary feature and as the game is stil in an early stage I decided to keep it for now. I used it to determine how to handle the landscape properly.
Title: Re: Hill Climb Racing
Post by: LDStudios on July 23, 2014, 05:20:30 pm
nice, I wasn't even aware of on.rightMouseDown :)
Title: Re: Hill Climb Racing
Post by: DJ Omnimaga on July 24, 2014, 01:31:29 am
Maybe as the game progresses you could add obstacles like hay bales that slows you down greatly and stuff that can kill you like cows slowly wandering around, rocks, nethams, holes and stuff like that.
Title: Re: Hill Climb Racing
Post by: CinusMinus on July 24, 2014, 05:28:15 am
Holes should be possible, but other obstacles than steep slopes could be a problem, because you can't avoid them in a 2D world. Things that slow you down should be possible though
Title: Re: Hill Climb Racing
Post by: DJ Omnimaga on July 24, 2014, 10:57:01 am
what if they were placed just after jumps and the like?
Title: Re: Hill Climb Racing
Post by: CinusMinus on July 24, 2014, 11:14:27 am
That would of course be pssible, but the script would have to find places that can be avoided by jumping over them. I'll wait for that until I have finished the basic game.
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on August 19, 2014, 06:56:06 pm
A month later doublepost seems okay :)
After being on holiday for two weeks I've been coding again and finished an improved version of HillClimbRacing.
It features:
- dynamic car-loading from tables: this might be interesting for loading addons
- fuel (needs some improvement): You can only race as long as you have enough fuel
- a new and better car
- better vehicle physics (springs are working now)

Problems:
- post-step callbacks crash the emulator, but works fine on real hardware. Quick workaround provided
- the game runs really slow on the calc and I'm not sure what to do :(

Plans for next versions (unsorted):
- dynamically loadable maps
- control of vehicles in flight
- coins
- better fuel
- menu and GUI
- highscores
- upgrades
- driver who can break his neck
Title: Re: [Lua] Hill Climb Racing
Post by: Vsod99 on August 19, 2014, 08:48:14 pm
It told me I needed an update... then I realized that I had been using my 3.1 cas os on my cx lol. Switched to 3.6, tried it out, and it's definitely nice! Looking forward to future updates :D
Title: Re: [Lua] Hill Climb Racing
Post by: Princetonlion.tibd on August 19, 2014, 09:08:57 pm
Add nethams  (blue lobsters) :D

(and sunfishes :P)
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on August 21, 2014, 12:14:34 am
I'll give this a try when I decide to install nLaunchy+OS 3.6. Could someone make an animated screenshot or video?
Title: Re: [Lua] Hill Climb Racing
Post by: Adriweb on August 21, 2014, 06:40:14 am
Haha I can launch my car by dropping ones on it, thus cheating... :evil: :P

Anyway, it's fast enough on TINCS, but I'm too scared to try on the handheld :(
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on August 25, 2014, 07:00:32 pm
Another Update:

New Features:
- Fancy driver who dangles around in the car and breaks his neck if you are not careful enough :)
- You can restart the game without closing the document
- Better fuel-distribution
- Vehicles can be rotated in mid-air
- Highscores which can be restored after reopening the document (They won't survive the next update though)

After some small adaptations it runs surprisingly fast and smoothly on the handheld. It still runs better in the emulator though :D

Planned for the next updates:
- Menu System
- More Tracks
- More Cars
- Coins (I'm not sure whether they should be coins or something else)
- Some Secret Features :P
Title: Re: [Lua] Hill Climb Racing
Post by: Vsod99 on August 25, 2014, 07:45:14 pm
Another Update:

New Features:
- Fancy driver who dangles around in the car and breaks his neck if you are not careful enough :)
- You can restart the game without closing the document
- Better fuel-distribution
- Vehicles can be rotated in mid-air
- Highscores which can be restored after reopening the document (They won't survive the next update though)

After some small adaptations it runs surprisingly fast and smoothly on the handheld. It still runs better in the emulator though :D

Planned for the next updates:
- Menu System
- More Tracks
- More Cars
- Coins (I'm not sure whether they should be coins or something else)
- Some Secret Features :P
Cool! I'll try it out now.
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on August 28, 2014, 06:11:39 pm
Simple Menu System is there now with a brand new car and and another track :)
Check it out
VVVVVVV
Title: Re: [Lua] Hill Climb Racing
Post by: LDStudios on August 29, 2014, 02:20:47 pm
Nice work!
I think the cars should definitely have higher acceleration though, because i keep getting stuck, and its impossible to make any good jumps.
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on August 30, 2014, 02:14:39 am
I'm working on upgrades you can buy for coins collected ingame to solve that problem. But that will take some time as I'm on holiday for a week now and school starts after that, so I'll have less time to work on the game. Upgrades are the next feature I want to implement though.
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on August 30, 2014, 02:24:20 am
The next updates will take some time as I'm on holiday for a week now and school starts after that. But the next planned feature is an upgrade system to improve your car. The upgrades will have to be bought with coins (or nethams) collected ingame. With these it will be possible to get further without getting stuck.
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on August 30, 2014, 10:06:19 pm
Ah ok, good luck with school and hopefully you have some free time. :)
Title: Re: [Lua] Hill Climb Racing
Post by: Princetonlion.tibd on August 31, 2014, 12:58:01 am
So do you run into Nethams (blue lobsters) in the road to gain nethams?
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on September 29, 2014, 06:07:07 pm
It's finally there: the newest version with coins and upgrades included :D
I finally chose coins, because they are a bit more handy than giant chunky lobsters and small lobsters just don't look good.
(http://i.imgur.com/VDc8lnf.png)

New Features:
- Upgrades, which help to get further
- Coins to buy upgrades

Plans:
- Add some more cars and tracks you can unlock (and of course a feature to unlock cars and tracks  ::) )
- adjust prices, but I'll wait for your feedback first :)
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on September 29, 2014, 07:10:18 pm
Awesome :D, too bad the lobsters didn't work out :P
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on October 01, 2014, 12:58:49 pm
Well lobster still haunt the code, but that's not such a big deal >B) .
A much more severe problem is that the file I uploaded yesterday doesn't work ::) . I didn't notice because the error is caused by restoring a saved document. When using the built-in editor of the student software this doesn't matter, so I didn't notice until I tried to run it on my calc and failed. So I upload the working version here
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on October 22, 2014, 10:13:27 am
The next version is available now :)
New Features:
- pause function
- popups when you attempt to buy something
- three different graphics modes
  - Abstract - only outlines, no sky - fastest on handheld
  - Medium - underground is not drawn
  - Full Everything is drawn
- new game-over screen
- a new track
- better performance on the handheld
- data is now stored in a variable to survive updates. To prevent cheating it's obfuscated

VV Download now VV
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on October 22, 2014, 11:41:00 am
Awesome :D, do you think the abstract graphic mode would work well on OS 3.1?
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on October 22, 2014, 11:57:55 am
It would, if there was a physics engine in 3.1. Unfortunately it isn't available on 3.1 and it's essential for running the game. So basically there earliest supported version is OS3.2, because of the physics engine. It would be possible to include the physics engine via ndless, but that would be a lot of work only to add a feature, that's already available on newer versions that also support ndless. I'm sorry, but it won't work on OS 3.1
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on October 22, 2014, 12:02:06 pm
Ah right, I forgot about the physics engine. I thought about the idea since LDStudios allows people to disable the background in his medieval platformer to increase speed.
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on October 22, 2014, 12:45:32 pm
That's quite similar to what I do here. I don't use sprites for the background though. On of the most costly operations is to recalculate the positions of the vertices every frame. That's necessary though a blind mode would probably be quite funny :) But by disabling the soil it gains some performance. The abstract mode just avoids filling shapes, which makes it faster, too.
Title: Re: [Lua] Hill Climb Racing
Post by: Adriweb on October 22, 2014, 01:23:33 pm
About the score/data saving without (for 99.99% users) a cheating possibility, I suggest taking a look here : http://inspired-lua.org/index.php/2011/08/save-a-high-score-without-cheating-possibility/ :)
(the code at the end, if you want to skip the rest)
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on October 22, 2014, 01:31:48 pm
I know about on.save and on.restore. but data saved in these methods doesn't survive an update. That's not that tragic, when you don't update at all or your game doesn't depend on previous sessions. but if you unlock something and then there is an update with a lot of new features, or even a small bugfix update all your data is lost. That's what I tried to avoid by storing the data into a variable. It's still not easy to cheat, because the text in the variable in unreadable. And as I want to maintain the possibility of updating without users losing their progress I implemented it that way.
Title: Re: [Lua] Hill Climb Racing
Post by: Adriweb on October 22, 2014, 03:36:15 pm
Hum, I'm not sure to understand what you mean...
By "update" you mean people downloading a new version of your tns, right ?

If so, then the "hcrdata" of the user wont' exist anymore since the .tns will be replaced by your file...

Or maybe what you mean is that people who update will have to copy/paste the lua code into their own tns file (which contains their hcrdata), and then, yes indeed only the lua code will be updated and the data will be still there :)

(Also, security by obscurity isn't really secure :P But yeah, it sure will prevent most cheaters I suppose ^^)

Also, just tested, it's pretty cool, good job.
Title: Re: [Lua] Hill Climb Racing
Post by: LDStudios on October 22, 2014, 05:05:18 pm
Hum, I'm not sure to understand what you mean...
By "update" you mean people downloading a new version of your tns, right ?

If so, then the "hcrdata" of the user wont' exist anymore since the .tns will be replaced by your file...

Or maybe what you mean is that people who update will have to copy/paste the lua code into their own tns file (which contains their hcrdata), and then, yes indeed only the lua code will be updated and the data will be still there :)

(Also, security by obscurity isn't really secure :P But yeah, it sure will prevent most cheaters I suppose ^^)

Also, just tested, it's pretty cool, good job.

He might mean a way to copy the file data from the file without opening the script editor, and then ability to paste it into a future version. (or something like that)
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on October 22, 2014, 05:12:41 pm
I know that on the HP Prime, variables created by a specific program will not work with newer versions of that program. Maybe he meant something similar but with the Nspire?
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on October 22, 2014, 05:52:59 pm
My main intention was not to prevent cheating. And yes, when the user updates the new file doesn't contain the variable anymore. But there are at least three ways of updating without data loss:
1: Use the script editor and copy-paste the new lua code into the old program. 2:Copy the page of the new version to the file of the old version. 3: Overwrite the var in the new file with the old state, close the file and reopen it. As I said my main intention was to provide a way to keep your old highscores and your unlocked cars and tracks. If you really want to cheat you can always do it. It's easier when the savestate is accessible but that's acceptable. The problem is that any kind of data saved via on.save will be bound its script. The only other way would probably be to let the user insert the old state directly in the script. That wouldn't be much more safe though. Obfuscation will prevent most attempts to cheating, but other methods won't ban cheating completely, too.
Title: Re: [Lua] Hill Climb Racing
Post by: Alex Twigg on October 22, 2014, 07:02:59 pm
looks awesome! mind id i look at the code?
Title: Re: [Lua] Hill Climb Racing
Post by: LDStudios on October 22, 2014, 07:23:37 pm
looks awesome! mind id i look at the code?

The project is open source (as are pretty much all nspire lua projects), so I'm sure he wouldn't have a problem with it.
Click Script Editor, Edit Script in the student software, while that document is open.
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on October 22, 2014, 08:19:41 pm
Isn't there a free alternative to student software to look at Lua source code?
Title: Re: [Lua] Hill Climb Racing
Post by: LDStudios on October 22, 2014, 08:52:52 pm
Isn't there a free alternative to student software to look at Lua source code?
Yes, I think  you can use luna (http://www.omnimaga.org/news/%27luna%27-is-here-and-converts-your-lua-files-into-3-0-2-compatible-tns-files/), but its much easier to use student software, and I assume he has student software, since he has an nspire.
Title: Re: [Lua] Hill Climb Racing
Post by: Adriweb on October 22, 2014, 11:50:42 pm
No, Luna is to make a tns, not extract one :)

A free altermative would be a ram dump while running it in the emu.
Or if you have Ndless 3.1, use tns2xml...
Title: Re: [Lua] Hill Climb Racing
Post by: DJ Omnimaga on October 23, 2014, 01:55:51 am
Yeah I was wondering since some people buy their Nspires on the secondary market (especially people who need Ndless and are looking for an older hardware) and thus, won't get a Student Software license.
Title: Re: [Lua] Hill Climb Racing
Post by: CinusMinus on October 24, 2014, 04:08:56 pm
For all those who can't access the student software for whatever reason: The source code.
If there is an other way to open documents you could do a memory dump and search for lua code. I've used that to recover unsaved code from the student software after it had crashed. You can even access protected code that way. But it could also work with other software that can open nspire documents.
edit: I've just tested that method with nspire_emu and ndless_installer.tns and it worked. So you can retrieve the source files from scripts even when you don't have the student software. Just do the memory dump and search for some lua pattern. There is some other stuff, probably from the OS, but the lua source code of the current document can also be found.
Title: Re: [Lua] Hill Climb Racing
Post by: aeTIos on November 08, 2014, 06:41:58 pm
Just saw this thread. It's sad that I can't try this, because I have OS 3.1 and I'm not updating <_< Maybe I can dual boot one time. 
Though, judging from the looks this looks like an awesome project :D