Don't have an account? Register now to chat, post, use our tools, and much more.
Laser Game CSE
When I was young, I played a very nice game with a laser and a target. Now I remembered that and I want to make it for my calc. So I started and voilą, here is my game.

Things to do:
- Winner/loser check
- Multiple levels
- A better look-up
And probably a lot more.

The most tricky part, is some seq(real( stuff, which works, as I don't expected.

Here's a .gif of it (sorry, it is a bit laggy)

And here is the full code, optimizations are welcome.

Code:
ClrHome
If 80>det([[20
Then
Disp "Get DoorsCSE to run this:","http://dcs.cemetech.net"
Return
End
DelVar [A]{15,20->dim([A]
"rowSwap(LASER3"->Str0
1:det(0
expr(Str9->A
2:det(0
expr(Str9->B
For(A,1,dim(|LB
1->[A](|LB(A),|LA(A
End
"LASER"
real(5,0,0
3:det(0
real(0,1,1
seq(real(3,0,0,0,20,9,0,0,19,14,X),X,1,0,~1
max(1,min(20,A+sum(DeltaList(K={2,3->A
max(1,min(15,B+sum(DeltaList(K={4,1->B
For(C,1,2
real(7,8,8A-8,8B-8,8,8,1
real(7,8,8A-8,8B-8,8,8,0
End
If [A](B,A) and max(K={49,53
Then
2+(K=49->[A](B,A
8A-8->S
8B-8->T
seq(real(7,5,S,Ans+7,S+7,Ans,128+103(K=53),X),X,1,0,~1
seq(real(7,5,S,T,S+7,T+7,231-103(K=53),X),X,1,0,~1
End
real(2,0,0->K
End
If K=55
Goto A
164->A
64->B
DelVar D~1->C
Repeat A<8 or A>164 or B<4 or B>126
real(7,3,A-8,B-4,255,1,1
real(7,3,A-8,B-4,255,1,0
A+C->A
B+D->B
If not(max(fPart(8^^-1{A-4,Ans
Then
[A](B/8,A/8-.5->S
If 1<Ans
Then
C->E
Dnot(C)(1-2(S=3->C
Enot(D)(1-2(S=3->D
End
End
End
Lbl A
seq(real(0,3,4,255,X),X,1,0,~1
real(0,1,0,1

When all is ready, I want to upload it to the Archives. Hope you enjoy it!
That is a very cool idea! I assume there is a map that is generated, and you make the line to guide the pixel? How is the map generated?

Hey this looks really good!

I was wondering if the line colour was configurable?
Unicorn wrote:
That is a very cool idea! I assume there is a map that is generated, and you make the line to guide the pixel? How is the map generated?
I made a map with real(3,0 etc, but since it exists only of yellow squares, I might change that.
And the program didn't draw the white line, that is the pixel, since I don't erase it.
tr1p1ea wrote:
I was wondering if the line colour was configurable?
Yet not, it is now white, but I might implement it.
KermMartian wrote:
No, I've never seen this before.

If I can find the original game again, I will post a link.
Ah, I see, it is quite a bit different from Laser Mayhem at second watching. In this game, you place the mirrors everywhere, while in Laser Mayhem, there are a few mirrors that you can turn (and other obstacles you can manipulate), but everything on the map is already there. I stared at your laser movement loop for a bit, trying to figure out how it could be optimized a bit, and two things jump out to me:
1) You should switch the map to the active GRAM when the laser starts being fired, and then just draw on the active (on-screen) GRAM without flipping buffers. This will be a lot faster than displaying to both buffers. In other words, assuming that you flipped the active GRAM onto the LCD before the loop, you'd only need the second line of this:
Code:
real(7,3,A-8,B-4,255,1,1
real(7,3,A-8,B-4,255,1,0

2) Your not(max(fPart line, which I believe checks whether A-4 mod 8 or B mod 8 are zero, seems overly complex for what it does, but I'm not sure what a better solution is. I assume that not(min(remainder({A-4,Ans},8 is not an option?
very cool! there's a game similar to this on lumosity, except it's where you have to look at the board for a few seconds, then it disappears, and you have to guess where the ball ends. just like how your laser bounces off the mirrors.
KermMartian wrote:
Ah, I see, it is quite a bit different from Laser Mayhem at second watching. In this game, you place the mirrors everywhere, while in Laser Mayhem, there are a few mirrors that you can turn (and other obstacles you can manipulate), but everything on the map is already there. I stared at your laser movement loop for a bit, trying to figure out how it could be optimized a bit, and two things jump out to me:
1) You should switch the map to the active GRAM when the laser starts being fired, and then just draw on the active (on-screen) GRAM without flipping buffers. This will be a lot faster than displaying to both buffers. In other words, assuming that you flipped the active GRAM onto the LCD before the loop, you'd only need the second line of this:
Code:
real(7,3,A-8,B-4,255,1,1
real(7,3,A-8,B-4,255,1,0

Wow, thank you a lot! And then I can save even more bytes by saying real(8,1,not(real(8,0 at the beginning, and then never update the LCD, always use real(....,0). I'm yet under the 700 bytes, with loser/winner detection!
I finally worked on it and it is finished now! (v1.0)
Take a look

And the code, optimizations are always welcome . In a few days I will upload it to the Archives.

Code:
ClrHome
If 80>det([[20
Then
Disp "Get DoorsCSE to run this:","http://dcs.cemetech.net
Return
End
Lbl 4
Lbl 3
Return
Lbl 2
ClrHome
Disp "Color laser (1-255):
Repeat K=105
getKey->K
Output(2,1,"<
Output(2,2,Z
Output(2,3+int(log(Z)),">
min(255,max(1,Z+sum(DeltaList(K={24,26->Z
End
Goto 4
Lbl 1
DelVar [A]{15,20->dim([A]
"rowSwap(LASER3->Str0
1:det(0
expr(Str9->A
2:det(0
expr(Str9->B
real(0,1,1
real(8,1,not(real(8,0
"real(7,8,8A,8B,8,8->Str5
Repeat A=136 and B=127
real(0,3,4,0
For(A,1,dim(|LB
1->[A](|LB(A),|LA(A
real(7,9,8|LA(A)-8,8|LB(A)-8,8,8,231
End
real(7,5,159,56,160,64,224
real(7,5,128,119,136,119,224
DelVar KWhile min(K!={9,55
real(2,0,0->K
If K
Then
expr(Str5
max(0,min(19,A+sum(DeltaList(K={2,3->A
max(0,min(14,B+sum(DeltaList(K={4,1->B
If [A](B+1,A+1) and max(K={49,53
Then
2+(K=49->[A](B+1,A+1
real(7,9,8A,8B,8,8,231
real(7,5,8A,8B+7(K=49),8A+7,8B+7(K=53),128
End
expr(Str5
End
End
If K=55
Then
real(0,3,4,255
real(0,1,0,1
Goto 4
End
expr(Str5
160->A
64->B
{~1,0->X
Repeat 78<abs(A-82) or 61<abs(B-65
real(7,3,A-4,B-4,Z,1
A+|LX(1->A
B+|LX(2->B
If not(max(remainder({A,Ans},8
Then
[A](B/8,A/8
If 1<Ans
not(|LX)sum(|LX)(5-2Ans->X
End
End
End
real(0,3,4,255

As you can see, I made a homescreen, where you can edit the color of the laser too. Everyone may test it ofc. The appvar looks like

Code:
{7,7,8,8,8,9,9,9,9,13,13,13,13,15,15,16,16,16,17,17,17,18,18
{6,10,5,6,7,5,6,7,10,2,6,7,8,5,7,7,8,9,2,7,9,5,6
The first line are the x-values, the second one the y-values. I must add multiple levels but hadn't enough free time yet.
It looks like at the end of the prog you have a bit of a dirty home screen... You can see the 255 thing or whatever still on the top row.

Also, if you want to take the time, you could make your program look much better with a custom menu, at the cost of size of course. My idea is that you could have like lasers and mirrors on the sides of the menu that kind of depict what the game's about. Then in the center would be your different menu options.
Michael2_3B wrote:
Also, if you want to take the time, you could make your program look much better with a custom menu, at the cost of size of course. My idea is that you could have like lasers and mirrors on the sides of the menu that kind of depict what the game's about. Then in the center would be your different menu options.
Thanks, do you mean something like this, or should I use the Text(-command?

And yes, the laser is very very slow, if someone can make it faster, here is the code:

Code:
real(0,3,4,255,1
real(0,3,4,255,0
real(8,1,0
"LaserG
real(6,0,112,40,0,33,1
"ame CSE
real(6,0,0,40,0,33,1
"Play!Sett!Quit
real(6,0,127,48,0,33,1
"ings
real(6,0,0,56,0,33,1
real(7,8,105,37,160,38,1
real(7,8,~1,37,60,38
0->A
160->C
120->D
~2->E
~1->F
real(8,1,1
Repeat K=105
getKey->K
real(8,0->G
real(8,1,0
">"
real(6,0,112,48+8A,0,33,0
If K
real(7,9,112,48+8A,8,8,255
max(0,min(2,A+sum(DeltaList(K={25,34->A
real(8,1,G
not(real(8,0
If Cnot(Ans)>58 or D<37 or D>75 or CAns<105 and Ans
real(7,3,C,D,7,1,0
C+E->C
D+F->D
real(8,0
If C=160not(Ans
Then
160Ans->C
real(8,1,not(real(8,0
End
If D=120 or not(D
~F->F
If not(C or real(8,0)) or C=160real(8,0
~E->E
End
Ooh, that's actually not what I was thinking, but it does look pretty cool. If you were going to keep it though it should be much faster.

What I was thinking is just a static background image showing mirrors and lasers going everywhere, bouncing off them or whatever. You could try to add some animations on it but if you do it needs to be relatively fast to be worth it.

Edit: I do like the custom menu btw. It is pretty generic, but that should be fine
Why don't' you draw the laser using real(7,5 (DrawLine) to draw the laser?

Here.
First of all, I prefer a continuing laser, which is only possible with SetPixel.
Next, when doing that, I must always draw lines of 4 pixel, which would be (I think) difficult.
Oh, and do you like my homescreen?
Oh, that looks great! Just get rid of the status thing.
I've uploaded it to the Archives.
The only thing I need to do is create more levels, and of course then the possibility to choose a level before start.
Unicorn wrote:
Oh, that looks great! Just get rid of the status thing.
Thanks, and I did it. Check it out!
I'd recommend either slowly animating the menu drawing while the menu is running in the foreground (just add it stepwise while the getkey loop is running) or caching the menu in a picture after the first call and recalling it every time the menu is drawn, then deleting the cache pic at exit, because even that half second looks annoying. But other than that it looks good!

Edit: Maybe it also would be good animating something like an explosion on the tile that gets hit by the laser (game won) and putting a game won screen after that. Just an idea.
Hmm this game is almost an except clone of my game lazer! (Which is for the ti83+/ti84+)Except mine has portals and other goodies in the newer version Do to the fact that I am not a shameless advertiser, I will not post the link to it here unless someone wants it

Side note: Hello cemetech!
That title screen is amazing . Also the game seems well-done so far for this calc. I will definitively give it a try when it comes out.

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are GMT - 5 Hours

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