Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: hoffa on May 31, 2011, 12:11:08 pm

Title: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on May 31, 2011, 12:11:08 pm
Hey,

I yesterday started experimenting with Lua to see how well it handled graphics and other game-related stuff. I wrote on the other thread (http://ourl.ca/11287) about my results. Well it seems like the calculator is not fast enough to handle games where fluidity in the gameplay is an important factor (i.e. many platformers). It's not that the calculator itself is slow, it's just the way Lua has been implemented on it that makes it inefficient for such games (Edit: invalidate() is able to update the screen partially, so all that written before might be wrong). I then decided playing around with Pokémon-like games, where speed is not the most important thing. And that's basically where I'm at, at the moment. For now with what I have done it seems to be working well. This also helps me to test Lua in a "real-life situation", with title screens and everything that a game usually has, in order to see what the difficulty of making such a game is and whatnot.

Everybody loves screenshots, so I give you screenshots:
(http://webgel.net/bf/8/screen1.png)
(http://webgel.net/bf/8/screen.png)

It's not much (at least Ash can move and the basic tile "engine" is done), and I'm only in the experimenting/testing phase right now. I still have to see how to actually save an eventual game (it might be possible to do something with var.store() and its friends), if it is even possible, and many other things to see if it's even worth trying to make the game.

Spoiler For Spoiler:
It's Fuchsia because I didn't even know what kind of color fuchsia was, and also because it's such a manly color. (I don't even know how you pronounce "fuchsia")

That's it for now. :)

PS: Also notice the small black on the second screenshot at the bottom. By "removing" 4 pixels (which is the same width as the upper bar, so it's symmetrical and doesn't look ugly) I have a resolution of 318*208, which is a lot better (especially in a tile-based game) than normally.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Spyro543 on May 31, 2011, 01:23:55 pm
Looks awesome! I'll be getting an Nspire, hopefully. I hope you will continue, looks awesone!
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Ashbad on May 31, 2011, 01:40:14 pm
that looks great Hoffa!  I heard that graphics rendering for Lua is a slow stack-based method (For NLua, at least) -- what is the framerate right now?
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: DJ Omnimaga on May 31, 2011, 02:12:07 pm
That looks nice. If I was you however, I would start with a small Pokémon demo with only like 20 Pokémons maybe to not start too big. That's unless you have a lot of project and programming experience, though. I guess maybe there will be no smooth scrolling, right?

Fortunately Lua speed is better than nothing at least. It seems we can do pretty awesome stuff in it and the slow speed might encourage people to try finding new optimizing tricks in the process.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on May 31, 2011, 02:14:47 pm
that looks great Hoffa!  I heard that graphics rendering for Lua is a slow stack-based method (For NLua, at least) -- what is the framerate right now?
I can't really say as there is no real animation. It's also event-based so unless I make some sort of benchmarking thing with continuous animation it'll be hard to give an accurate framerate. But I'd say about 10-15 FPS, but it can be anything really.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on May 31, 2011, 02:18:43 pm
That looks nice. If I was you however, I would start with a small Pokémon demo with only like 20 Pokémons maybe to not start too big. That's unless you have a lot of project and programming experience, though. I guess maybe there will be no smooth scrolling, right?

Fortunately Lua speed is better than nothing at least. It seems we can do pretty awesome stuff in it and the slow speed might encourage people to try finding new optimizing tricks in the process.
What I really wanted to try here wasn't that much the Pokémon part, but the tile-based-game part. I'm not even thinking about the Pokémons and fights yet, just about how it would all work and checking the performance and stuff like that. When it comes to the slow speed, the problem is that if the most primitive functions are already slow, it'll be hard to optimize that.
Edit: about scrolling, well I think that kind of smooth scrolling you have on Pokémon would be hard and/or laggy. Insted what could be possible is the kind of Zelda-like "fake" scrolling (as on the NES version). But anyway, the screen is quite big and quite many sprites fit on it, so I don't think it will be a huge problem.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Adriweb on May 31, 2011, 02:20:29 pm
Great job ! It looks really great :)

By the way, when we documented the lua functions when we discovered them, we didn't know platform.window:invalidate() would accept arguemtns that specify *what part of the screen" you want to refresh.
This is really interesting since it can refresh the screen much faster then on the parts that change, and leave the screen as is when it doesnt need to get refreshed. Maybe  it will work better for your other experiments ?
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: SirCmpwn on May 31, 2011, 02:31:56 pm
Looks quite nice!
Also, try to avoid double posting in the future, and simply modify your post with new information.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on May 31, 2011, 02:32:27 pm
By the way, when we documented the lua functions when we discovered them, we didn't know platform.window:invalidate() would accept arguemtns that specify *what part of the screen" you want to refresh.
Goddamn, are you serious?! :o That's great news! That could fix many (if not all) of the framerate issues! I have to try that out, thanks for telling me that! :D That will help a lot.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Adriweb on May 31, 2011, 02:33:40 pm
That's why I told you ;)

It's there : http://wiki.inspired-lua.org/platform.window:invalidate (http://wiki.inspired-lua.org/platform.window:invalidate)
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on May 31, 2011, 02:43:29 pm
That's why I told you ;)

It's there : http://wiki.inspired-lua.org/platform.window:invalidate (http://wiki.inspired-lua.org/platform.window:invalidate)
This is so great. Just tried it out, Ash now moves faster than light (well you get the point). Having a lot of stuff on the screen might not be an obstacle after all!
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Adriweb on May 31, 2011, 02:44:36 pm
Glad it improved your things :)
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: DJ Omnimaga on May 31, 2011, 03:31:47 pm
Are you planning to eventually release the source code? It would be nice for people who wants a tilemapper :D
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on May 31, 2011, 03:42:42 pm
Are you planning to eventually release the source code? It would be nice for people who wants a tilemapper :D
Sure! This is what I have at the moment: http://pastebin.com/phnSAjKH (http://pastebin.com/phnSAjKH) (there's not much to see at the moment, I'll post the code again once I have cleaned it up and have some more interesting things. Edit: also there are things I still need to optimize, for example now it will redraw all the objects on the screen at every call at on.paint(), etc.)

Edit: new cleaned up and more consistent code: http://pastebin.com/0HPsh4vy (http://pastebin.com/0HPsh4vy)
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: DJ Omnimaga on May 31, 2011, 03:45:17 pm
Cool to hear. A good spot to upload it when completed might be the Lua sub-forum on the site and also the Nspired-Lua wiki :D
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: ztrumpet on May 31, 2011, 05:38:52 pm
It's Fuchsia because I didn't even know what kind of color fuchsia was, and also because it's such a manly color. (I don't even know how you pronounce "fuchsia")
It's pronounced similar to "few-shaw," but without the 'w' in shaw.  The color fuchsia is a purple color, similar to these: (Note how many people accidentally misspell fuchsia.)
Spoiler For Spoiler:
(http://imgs.xkcd.com/blag/fuchsia.png)

This project looks really nice!  Great job. :D
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on June 01, 2011, 11:26:38 am
Okay now Ash looks like he's actually moving, rather than just magically teleporting from one square to the other. Yeah, basic animation is working now (after hours I finally understood how invalidate() worked, forgot to check the wiki). Also I added some more sprites and cleaned up and structured the code better. There's not much to try, but at least you can move Ash around and enjoy the wonderful scenery: http://webgel.net/bf/fuschia_test.tns (http://webgel.net/bf/fuschia_test.tns) (best tried on the actual calculator though, it's too fast on the computer) Edit: it is still quite slow (but playable) at the moment, but there are still things I need to optimize, it'll be done later.
I'll now work on some basic interaction with objects and other stuff.
(http://webgel.net/bf/8/screen.png)

It's Fuchsia because I didn't even know what kind of color fuchsia was, and also because it's such a manly color. (I don't even know how you pronounce "fuchsia")
It's pronounced similar to "few-shaw," but without the 'w' in shaw.  The color fuchsia is a purple color, similar to these: (Note how many people accidentally misspell fuchsia.)
Spoiler For Spoiler:
(http://imgs.xkcd.com/blag/fuchsia.png)
Thank you good sir. o/
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Anima on June 01, 2011, 03:10:41 pm
Looks very nice. Why I haven't got a Nspire? o/
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on June 01, 2011, 03:14:48 pm
Ash can now somewhat interact with objects. A sign in this case.
(http://webgel.net/bf/9/screen.png)

Looks very nice. Why I haven't got a Nspire? o/
Because you aren't in a school that forces you to buy one. ;_;
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: ruler501 on June 01, 2011, 08:42:04 pm
Looks very nice. Why I haven't got a Nspire? o/
You like non locked up platforms
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: BrownyTCat on June 02, 2011, 12:15:48 pm
Are you planning to eventually release the source code? It would be nice for people who wants a tilemapper :D
Sure! This is what I have at the moment: http://pastebin.com/phnSAjKH (http://pastebin.com/phnSAjKH) (there's not much to see at the moment, I'll post the code again once I have cleaned it up and have some more interesting things. Edit: also there are things I still need to optimize, for example now it will redraw all the objects on the screen at every call at on.paint(), etc.)

Edit: new cleaned up and more consistent code: http://pastebin.com/0HPsh4vy (http://pastebin.com/0HPsh4vy)
Yay, samples. I can get started on my laggy TF2 platformer or whatever I'm doing! That's some clean code.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on June 06, 2011, 05:41:24 pm
I'm working on two projects at the moment and won't have the time to concentrate on this one specifically at the moment. The code started getting slightly messy and so I decided to write a library for tile-based games (with animation, events, interrupts (or interactions, whatever they're called) and other things practical in a game), and that's what I'm doing at the moment. I'm also writing a copter-like game. I got exams coming up also, can't ignore that, so don't except anything just yet.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: DJ Omnimaga on June 07, 2011, 04:18:50 am
Ah ok, sorry to hear. I hope you can work on both again soon  :)

A tilemapper will definitively be a good idea, since people often get stuck on that part, along with collision detection.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Hayleia on June 07, 2011, 06:46:38 am
Your project seems to have a problem: the map seems not to be scrolling.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Ashbad on June 07, 2011, 09:11:26 am
Your project seems to have a problem: the map seems not to be scrolling.

I've heard that it won't work that great with scrolling -- the rendering speeds just aren't fast enough.
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: hoffa on June 07, 2011, 09:32:54 am
Your project seems to have a problem: the map seems not to be scrolling.
Yeah as Ashbad said, the way Lua has been implemented on the calculator doesn't really allow smooth scrolling, as it would require to redraw the whole screen at every single step (and it's not even that fast without scrolling either). I might try doing something less smooth later (maybe Zelda-like on the NES, or just something that requires less redrawing) and see how it runs, but for now no scrolling (i.e. in the library I'm writing, not working on Pokemon at all right now).
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: Hayleia on June 07, 2011, 12:50:27 pm
Well, I'm ok with it, and I think everybody is. In my opinion, a good game is better than a stick-to-original game. But you won't be able to make exactly the same maps as in the original game (but I think that it is not important, and that this is not your goal or you would have called it Pokemon Yellow II).
Title: Re: [Nspire] Pokémon Fuchsia -- An experiment
Post by: BrownyTCat on June 09, 2011, 11:53:47 pm
A tilemapper will definitively be a good idea, since people often get stuck on that part, along with collision detection.
No glances at me? Wow.