Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 07:13:56 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityJams & EventsCompetitionsOld CompetitionsCockpit Competition[FINISHED] Luna
Pages: [1] 2
Print
Author Topic: [FINISHED] Luna  (Read 10222 times)
whitespace
Level 0
**


View Profile
« on: February 23, 2009, 09:07:48 AM »

I made an oldschool lunar landing sim,
It's in javascript,
I don't have a webspace to upload it though,
you can save it in notepad with html extension and play it,
or maybe someone is willing to upload it on his/her space?
Code:
<body onkeydown="k(event.keyCode)" style=font-family:monospace><script>
y=0;t=-1;h=550;v=45;f=150;k(48);
function k(e) {
if (e>47 && e<58 && h>0) {
y=e-48;t+=1;f-=y;if (f<0) {f=0;y=0};v+=(5-y);h-=v;if (h<0) {h=0};
if (h>0) {
document.body.innerHTML="TIME:"+t+"<BR>HEIGHT:"+h+"<BR>SPEED:"+v+"<BR>FUEL:"+f+"<BR>BURN FUEL UNITS: (INPUT 0-9)<BR>";
}
if (h==0 && v>5) {
document.body.innerHTML="TIME:"+t+"<BR>HEIGHT:"+h+"<BR>SPEED:"+v+"<BR>FUEL:"+f+"<BR>YOU ARE ON THE MOON.<BR>YOU LANDED WITH A SPEED OF "+v+" M/S, NOW YOU ARE DEAD.<BR>REFRESH TO TRY AGAIN.";
}
if (h==0 && v<6) {
document.body.innerHTML="TIME:"+t+"<BR>HEIGHT:"+h+"<BR>SPEED:"+v+"<BR>FUEL:"+f+"<BR>YOU ARE ON THE MOON.<BR>YOU LANDED SUCCESFULLY WITH A SPEED OF "+v+" M/S,<BR>IT TOOK YOU "+t+" SECONDS,<BR>YOU HAVE "+f+" FUEL UNITS LEFT,<BR>I WONDER WHAT YOU WANT TO DO HERE.<BR>REFRESH TO TRY BETTER.";
}}}
</script>

I'm sorry, something is drawing me to minimalism always.

[EDIT]
I made my first C-program,
it's the same game, but I'm kinda proud I finally made sth in C Smiley
http://www.willhostforfood.com/access.php?fileid=61169
« Last Edit: April 04, 2009, 01:04:21 PM by whitespace » Logged
genericuser
Guest
« Reply #1 on: February 23, 2009, 09:18:15 AM »

Luna has been uploaded here.

EDIT: Mirror's gone down.  Sad
Pretty neat game  Smiley
« Last Edit: March 12, 2009, 03:59:48 PM by genericuser » Logged
nihilocrat
Level 10
*****


Full of stars.


View Profile WWW
« Reply #2 on: February 23, 2009, 09:20:56 AM »

Clever game. The complete lack of visual presentation outside of some instrumentation (or at least very limited) is something that I am probably going for in my game.

Looks like someone beat me to the punch, here's a mirror:
http://nil.cjb.net/luna/
Logged

Traveller
Level 1
*


View Profile
« Reply #3 on: February 23, 2009, 10:01:29 AM »

Fun! Very minimalistic code that is still very playable!  I'm surprised how good the interface is, really.  Not having to press enter is great.  And replacing text instead of scrolling keeps the user's eye in the same place.

Personal best: Landed at 5 m/s, in 16 seconds, with 25 fuel left.
Logged
J.G. Martins
Level 2
**


AKA anvilfolk


View Profile WWW
« Reply #4 on: February 23, 2009, 10:03:58 AM »

Code:
TIME:21
HEIGHT:0
SPEED:5
FUEL:0
YOU ARE ON THE MOON.
YOU LANDED SUCCESFULLY WITH A SPEED OF 5 M/S,
IT TOOK YOU 21 SECONDS,
YOU HAVE 0 FUEL UNITS LEFT,
I WONDER WHAT YOU WANT TO DO HERE.
REFRESH TO TRY BETTER.

Woot! No fuel for takeoff. I really do wonder what I'm going to do on the Moon until the oxygen runs out!

For some stupid reason, I also started out thinking the numpad was the direction, but that was because I didn't read the cockpit instructions properly Wink
Logged

Gold is for the mistress -- silver for the maid --
Copper for the craftsman cunning at his trade.
"Good!" cried the Baron, sitting in his hall,
"But iron, cold iron, is the master of them all."
--- Rudyard Kipling
increpare
Guest
« Reply #5 on: February 23, 2009, 10:08:01 AM »

hard!  compelling, though.
Logged
ChrisFranklin
Level 1
*



View Profile
« Reply #6 on: February 23, 2009, 10:09:00 AM »

Quote
TIME:18
HEIGHT:0
SPEED:2
FUEL:12
YOU ARE ON THE MOON.
YOU LANDED SUCCESFULLY WITH A SPEED OF 2 M/S,
IT TOOK YOU 18 SECONDS,
YOU HAVE 12 FUEL UNITS LEFT,
I WONDER WHAT YOU WANT TO DO HERE.
REFRESH TO TRY BETTER.

What is "better?"  Softer landing?  More fuel left over?  Quicker time? Sad
Logged
ElTipejoLoco
Level 2
**

You can call me Edua.


View Profile WWW
« Reply #7 on: February 23, 2009, 10:38:54 AM »

I wish I could land in a crater. HEIGHT: -5

Okay, should go to class now.
Logged


Currently brainstorming for a project
nihilocrat
Level 10
*****


Full of stars.


View Profile WWW
« Reply #8 on: February 23, 2009, 12:37:35 PM »

What is "better?"  Softer landing?  More fuel left over?  Quicker time? Sad

Take a look at the source code. Look at all the possible "endings".

It seems someone has set us up for.... A SUICIDE MISSION! Noir
Logged

PGGB
Level 8
***



View Profile
« Reply #9 on: February 23, 2009, 02:40:38 PM »

That was fun.  Smiley
Logged
[platypus]
Level 0
***



View Profile
« Reply #10 on: February 23, 2009, 04:33:44 PM »

Nice gime, but I doubt that it's yours.  Shrug

I coded this very same game with QBasic when I was a kid, and I copied it out from a book I lended from library. It was some kind of "learn to program"-book. It had almost exactly the same words (in finnish, but still).

I'm not saying you couldn't enter with this, but since this has been done before, you should propably make a new game or improve this one.
Logged
Fuzz
Guest
« Reply #11 on: February 23, 2009, 05:10:59 PM »

If that's true, this is very ungentlemanly of you, whitespace. Try to be more Gentleman.
Otherwise, cool game.
Logged
whitespace
Level 0
**


View Profile
« Reply #12 on: February 23, 2009, 09:07:10 PM »

Well, I certainly didn't had the intention to be no  Gentleman.
But you're right, for the people that haven't had zx81 or something equal:
I didn't invent this game, the idea was written 30 years ago. There are several authors of several games on several platforms that have done same thing before. I seriously thought of this type of game as a genre. I'm sorry if it looked like I tried to be refreshing by taking things from the very past.

Besides that I don't really understand why I would not be capable to write such simple game myself?

I do think about the possibilities of making this game grow. I like the fact that you're looking at some bare-naked numbers, and still feel something through your fantasy.
Logged
whitespace
Level 0
**


View Profile
« Reply #13 on: February 23, 2009, 09:11:20 PM »

Quote
TIME:18
HEIGHT:0
SPEED:2
FUEL:12
YOU ARE ON THE MOON.
YOU LANDED SUCCESFULLY WITH A SPEED OF 2 M/S,
IT TOOK YOU 18 SECONDS,
YOU HAVE 12 FUEL UNITS LEFT,
I WONDER WHAT YOU WANT TO DO HERE.
REFRESH TO TRY BETTER.

What is "better?"  Softer landing?  More fuel left over?  Quicker time? Sad

Yep! Funny isn't it, how much depth in four variables?
You can even try to make the slowest succesful landing.
Logged
Fuzz
Guest
« Reply #14 on: February 23, 2009, 09:34:03 PM »

Well, I certainly didn't had the intention to be no  Gentleman.
But you're right, for the people that haven't had zx81 or something equal:
I didn't invent this game, the idea was written 30 years ago. There are several authors of several games on several platforms that have done same thing before. I seriously thought of this type of game as a genre. I'm sorry if it looked like I tried to be refreshing by taking things from the very past.

Besides that I don't really understand why I would not be capable to write such simple game myself?

I do think about the possibilities of making this game grow. I like the fact that you're looking at some bare-naked numbers, and still feel something through your fantasy.
Well, this is fine if you're taking the basic idea and running with it, which is what it seems like you're doing. If so, good job, sir.  Gentleman
Logged
Traveller
Level 1
*


View Profile
« Reply #15 on: February 23, 2009, 09:39:51 PM »

Yep! Funny isn't it, how much depth in four variables?
You can even try to make the slowest succesful landing.

There's only so much space to experiment sadly.  To eventually stop, you need to expend 5 units of fuel per turn overall, plus 45 for a safe landing.  150 units of fuel means 21 seconds is the longest you can stay in the air.  Now I feel like a rocket scientist.  Wizard
Logged
whitespace
Level 0
**


View Profile
« Reply #16 on: April 04, 2009, 01:05:19 PM »

I made my first C-program,
it's the same game, but I'm kinda proud I finally made sth in C Smiley
http://www.willhostforfood.com/access.php?fileid=61169
(sorry windows only)
the source is probably kinda embarrassing, but here you go:
Code:
#include <curses.h>

int main()
{while(1){
 int row,col;
 int y=0;
 int t=-1;
 int h=550;
 int v=45;
 int f=150;
 int e=48;
   
char tit[] = "      ";
char title[] = " LUNA ";
char author[] = "by Whitespace";
char cockpit[] ="Tigsource Cockpit Competition 2009";
    initscr();
    curs_set(0);
    raw();
    noecho();
    clear();
    start_color();
init_pair(1, COLOR_BLACK, COLOR_WHITE);
attron(COLOR_PAIR(1));
    getmaxyx(stdscr,row,col);
    mvprintw(row/2-1,(col-strlen(tit))/2,"%s",tit);
    mvprintw(row/2,(col-strlen(title))/2,"%s",title);
    mvprintw(row/2+1,(col-strlen(tit))/2,"%s",tit);
    attroff(COLOR_PAIR(1));
    mvprintw(row/2+3,(col-strlen(author))/2,"%s",author);
    mvprintw(row/2+4,(col-strlen(cockpit))/2,"%s\n",cockpit);
    getch();
    clear();
    while (h>0) {
          clear();
          y=e-48;
          t+=1;
          f-=y;
          if (f<0){
                   f=0;
                   y=0;
                   };
          v+=(5-y);
          h-=v;
          if (h<0){
                   h=0;
                   };
          mvprintw(10,35,"Time:%d",t);
          mvprintw(11,35,"Height:%d",h);
          mvprintw(12,35,"Speed:%d",v);
          mvprintw(13,35,"Fuel:%d",f);
          attron(COLOR_PAIR(1));
          mvprintw(15,25," Burn fuel units:(press 0-9) ");
          attroff(COLOR_PAIR(1));
         
          if (h==0 && v>5){
                   clear();
                   char fail1[] = "You are on the moon.";
                   char fail2[] = "You landed too fast.";
                   char fail3[] = "Now you're dead.";
                   mvprintw(row/2-1,(col-strlen(fail1))/2,"%s",fail1);
                   mvprintw(row/2,(col-strlen(fail2))/2,"%s",fail2);
                   mvprintw(row/2+1,(col-strlen(fail3))/2,"%s",fail3);
                   break;
                   };
          if (h==0 && v<6){
                   clear();
                   char succ1[] = "You succesfully landed on the moon.";
                   char succ2[] = "I wonder what you want to do here.";
                   mvprintw(row/2-1,(col-strlen(succ1))/2,"%s",succ1);
                   mvprintw(row/2,(col-strlen(succ2))/2,"%s",succ2);
                   break;
                   };
                   e = getch();
          while(e<48 || e>57){
                     e = getch();
                     }         
                   
          }
          getch();
          }
endwin();
return 0;
}

   

 
Logged
Fuzz
Guest
« Reply #17 on: April 04, 2009, 02:47:03 PM »

It looks much nicer now! Gentleman
Logged
Cymon
Level 9
****


Computer Kid


View Profile WWW
« Reply #18 on: April 10, 2009, 08:01:02 AM »

Aw, you know I love this game. Why didn't anyone tell me about it!

Can I put this game on Cymon's Games?
Logged

Cymon's Games, free source code, tutorials, and a new game every week!
Follow me on twitter
whitespace
Level 0
**


View Profile
« Reply #19 on: April 11, 2009, 03:54:16 AM »

Cymon:
I feel honoured, you may put it up on your site.

I've been visiting your site frequently last weeks, cause I want to learn programming old C with Curses, and there are some nice, clean and simple examples on your page. Could you guide me to some good places on the internet where they specifically talk about C with Curses (Yes I've used google, only the info is pretty scattered I think)? +What is the best active curses-community on the net from what you know?
I want to learn C while using curses directly from the start, instead of learning C with stdio first. Or do you think I should learn C from the simple tutorials (that use stdio) first and get into curses soon?

Thanks for your interest, and thanks in advance for your answer.

 
Logged
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic