Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: {AP} on February 13, 2009, 12:24:33 pm
-
(http://img88.imageshack.us/img88/1412/nyaarscrolltitlevo6.gif)
(Note: Attached to this post is the Pic that you can use for this tutorial and the final program.)
The key to the scrolling background is order and only updating the LCD once per cycle.
For a basic background that scrolls rain down and to the left with nothing else, here's the code. I'll explain it in depth afterwards.
:0→X
:0→Y
:real(0
:Repeat 0
:identity(8,"2040840810000000",X,Y,0,1
:X-1→X
:Y-1→Y
:End
The first question you'll probably ask is the about "identity(8,...".
It's syntax is as follows:
identity(8,"HEXSTRING",right,down,LOGIC,UpdateLCD
"HEXSTRING" = 16 digit long hex code for the sprite in question. I made the rain sprite earlier
down = Pixels down the screen. Limit is -99999 to 99999.
right = Pixels to the right of the screen. Limit is -99999 to 99999.
LOGIC
0 = Overwrite (what you'll use most likely)
1 = And
2 = Or
3 = XOR
UpdateLCD
0 = No update
1 = Update
As you might have noticed, it looks like you can only go down and right.
Well, if you go right a negative amount, you go left. Same is true for down.
Now, you want something on top of your scrolling background.
You'll need to make a picture. Everything black stays black and white will be 'transparent'.
Just draw something up quick. (or download the pic in the attachment and use that... it's Pic3)
Now, to get it to show up. We'll need to modify the above code.
:0→X
:0→Y
:real(0
:Repeat 0
:identity(8,"2040840810000000",X,Y,0,0
:real(3,<your pic number>,3,1
:X-1→X
:Y-1→Y
:End
You'll notice 2 changes. First, the 'identity' code ends with a '0' now.
Second, you have the 'recall pic' command out and it DOES update the LCD.
If you want to know why they're not both updating... try it out with both.
Like the 'flicker' you see? I didn't think so.
Now, you're probably wondering how to make a white space on the screen.
How about one with a black border? For this example, we'll do that one.
:0→X
:0→Y
:real(0
:Repeat 0
:identity(8,"2040840810000000",X,Y,0,0
:real(3,<your pic number>,3,0
:real(12,9,13,25,44,61,1 //real(12,9,x1,y1,x2,y2,update
:X-1→X
:Y-1→Y
:End
Once again, we're only updating the screen once, and it's the very last time.
The bounds for the box can be changed how you like. This is the box for Nyaar!'s title screen.
Now, you want text in that box, right?
The easiest way to do it is to make sure the pic you made has the text on it where you would like it to appear. (in this case, in the box)
For this box, you have room for 5 options and about 6 characters long.
Option(X,Y)
New(15,26)
Load(15,33)
Help(15,40)
Credits(15,47)
Quit(15,54)
But, if you look at our current code... it seems that the box will overlay the text. Well, this is because of ordering.
Switch the order of of the Pic and Box.
:0→X
:0→Y
:real(0
:Repeat 0
:identity(8,"2040840810000000",X,Y,0,0
:real(12,9,13,25,44,61,0
:real(3,<your pic number>,3,1
:X-1→X
:Y-1→Y
:End
Once again, only one update and make sure it's the last one.
Finally, you'll want to have the options selectable.
This is my code for it, the important part is where you put the "real(12,8,...".
(Also note that this is for the box I made. The x's and y's will be different for you if you used another.)
:0→X
:0→Y
:1→M
:real(0
:Repeat K=105
:getKey→K
:M+(K=34)(M<5)-(K=25)(M>1→M
:identity(8,"2040840810000000",X,Y,0,0
:real(12,9,13,25,44,61,0
:real(3,<your pic number>,3,0
:real(12,8,14,26+7(M-1),43,32+7(M-1),1
:real(12,8,14,26+7(M-1),43,32+7(M-1),0
:X-1→X
:Y-1→Y
:End
Now, you might be confused with why there's not only a duplicate of the 'box' that shows what option is selected.
Not only that, the last thing does not update the LCD.
This has to do more with logical thinking. What it's doing is the first one highlights the selected option and shows everything you've done before it.
The second one un-highlights it, but doesn't show you that you've un-highlighted it.
By the time it DOES update, it'll have highlighted whatever the selected option is. Whether or not it's the same.
(http://img518.imageshack.us/img518/2681/tutmq0.gif)
Well, now you have a working title screen.
After the 'End' you can add the 'If M=1:Then:<Do whatever>:End:Etc...' to make the options actually do something.
Of course, M=1 is the first options, 2 the second, etc.
If you have any questions, ask me.
-
shit, this is awesome, {AP}!
-
Thank you. =D
It only took about an hour (maybe 2) of playing around with what Iambian said.
I do think that at least 16x16 sprites should be possible at least. (I know you'll read this, Iambian.)
Um... do you think I should add a short tutorial for how hex coded sprites work?
(EDIT: I did anyway, check the second post.)
EDIT 2011: Split sprite tutorial into individual topic due to the new tutorial section only fetching the first post http://ourl.ca/11553
-
Very nice work there, I can not remember how nickachu did his but I think cletics hex sprite makes it a little easier/quicker..Thanks!
-
No problem. Helping out the community is what I do. ^_^
-
Woot thanks. Heh I think I'll have to use this in just about every program I do from now on..
-
As an extra note... if you only want it to scroll in one direction, make the other constant (usually 0).
Example:
:identity(8,"2040840810000000",X,0,0,1
Only goes left or right. (depending on whether you add or subtract X)
:identity(8,"2040840810000000",0,X,0,1
Only goes up or down. (depending on whether you add or subtract X)
-
you know, can this be used possibly for parallax scrolling, maybe? i don't see a lot of that in calc games.
-
this is awesome, but do we really have to mess with Hex? Or is there an alternative compatible with xLIB? I think Bowling used xLIB and had scrolling. I am curious because I get confused easily when trying to make sprites using hex code and end up with trial and error until it displays right x.x
-
If xLIB is capable, I have no clue how one would get it to work.
Well, I guess that's where Nitacku rushes in to save the day.
I personally don't mind the hex thing. Less sprites to draw on a Pic.
-
anyway, what do you guys think of parallax scrolling? think i can modify these commands to do so with operators and LCDupdate?
EDIT: post 333 lol.
-
Even without that command parralax scrolling would be easily possible. With Celtic method, just move the background position by like 2 or 4 pixels when your character moves one tile, in the same direction than you moved. However, for that, you need to use masking for your tilemap displaying, in the same fashion than how the scrolling backgrounds have to be displayed. I only attempted it once as I said, but I had a static background. It can be slow, but I doubt it would be as slow as high quality 4 level xLIB/Celtic grayscale
-
hmm, I was beaten to the punch :P
I have yet to reveal the animated scrolling background, which i will do, as soon as i write the tutorial.
I've also got some interesting masking techniques that you might enjoy.
-
I can't wait ^^
SHould we move this topic in the Help section and pin it?
-
hmm, maybe we should create a massive Celtic/xLIB tricks & techniques tutorial.
I know general tutorials already exist, but there are no special tutorials combining everything the community has to offer.
-
i wish i could help, but i have yet to discover anything useful, lol :)
-
I'm probably gonna go ahead and write up a small tutorial involving some of the technical functions that might go right over BASIC users' heads. Like how to use the binary read/write functions and its bin/hex/dec converter to extract useful information out of it, so that you can effectively have a variable keeping track of "int" data instead of bulky float (real) vars.
-
Hm... when these tutorials get written up, do any of you (Nitacku and Iambian currently) mind if I post them on my site?
Proper credit will be given, of course.
-
only a jerk would say no anyway ;)
-
Haha, true. Still, it's common courtesy to ask first.
Speaking of such, I should update the site's tutorial page.
Be back in a few minutes. Or hours.
ADD is one hell of a mental condition. ^_~
-
ADD? you has it?
when i was twelve, one out of two doctors diagnosed me with ADD. however, since we never pursued any sort of treatment or anything. i assumed i didn't have it.
-
Has it.
Still finished.
All video tutorials and this tutorial are now on my site (http://anti-pi.webs.com).
-
hmm, maybe we should create a massive Celtic/xLIB tricks & techniques tutorial.
I know general tutorials already exist, but there are no special tutorials combining everything the community has to offer.
It could bring great graphics games in BASIC by more more people. ^^
You are making me to start using xLib/CelticIII...
-
actually on TI-BD it might be a good place, since there is alerady the xLIB Guru there, but it's ok on your site. Just make sure to have a copy on Omnimaga in case your webhost went down or if your site got cracked. x.x
-
only a jerk would say no anyway ;)
wat aboot a toal beef jerkiee???
-
if you stare at the screenshot, it goes from looking like snow to like a rocket going up to a vertical view of a plane over water.
sorry i just wanted to let everyone know that...
-
if you stare at the screenshot, it goes from looking like snow to like a rocket going up to a vertical view of a plane over water.
Drugs are bad
-
if you stare at the screenshot, it goes from looking like snow to like a rocket going up to a vertical view of a plane over water.
Drugs are bad
They really are.
-
not if they're free
-
I think... this is the first time I've seen the topic. Gawd, gotta check here more often and stuff.
But, on a much earlier note, 16x16 should be possible, but I did 8*8 because the ASM code used for that was extremely simple to get working. I may make an extension to the same command some time later. My plan: Check the string as to whether or not it'll make a 8*8 tile or a 16*16 tile. Nothing else should be needed.
-
Oooo... 16x16 would be fun to play with too.
I'll mess with it at a later date though.
Busybusybusy..
-
Busybusybusy..
Nyaar Raycaster edition
-
Busybusybusy..
Nyaar Raycaster edition
Now that would be sweet
-
Screw raycasting we need raytracing.
-
We need to port Crysis to 84's
-
Offtopic, much?
If you want 16*16 sooner, why don't you put up some code for it?
-
Noahbaby drifted, i drifted more :)
-
onto UnSS I see
-
hmm, I just noticed a slight optimization you could make to the code, at the start where it goes
:0->X
:0->Y
you could change that to :Delvar XDelvarY
it would save 3 bytes I believe
EDIT: upon closer inspection I found another optimizations, replace:M+(K=34)(M<5)-(K=25)(M>1→M
with this::M+(K=34 and M<5)-(K=25 and M>1→M
so that brings the total bytes saved to 5...
-
I coded this thing too fast. Thanks for the optimizations though.
Sometimes you just don't notice these things, eh? =P
-
yeah, I always see them when I go back through my code, afterwards I always wonder what I was thinking when I used that piece of code
-
I moved this in help and support because since it was in another project forum it wasn't visible too much for those who wants help x.x
-
Ya, this is a necro-post. But oh well, just letting people know that {AP}'s tutorials are now in the Tutorial thread :)
-
Nice :)