Hi Guys,
I got a little bored with my static battleship game. I also wanted to know if a way existed to read user input without breaking a loop (I need to do this for something else). So called "non-blocking user input", which is simple in other languages but I had no idea if this could work in R easily. For instance scan, menu, readline all don't have this functionality.
So I thought I might try to crack it by making a clone of a classic dos game. Platform games are too complex but a speed type game should be ideal. However after playing around the only way I can think of to do this (implement "non-blocking user input") is via a connection to a file. So I implement a GUI from e.g. a C++ code, and then type my words in there, which changes the contents of a file.. which can then be read by R. A major pain to say the least. You guys have any ideas on how to implement "non-blocking user input"?
How to play? In this early beta version you will need to open both R and a file editor. Copy & paste the code into R or use source(), then type "typespeed()" and the game should start. You can choose out of 3 libraries (please help me improve these, or add suggestions for your own). Make sure you open the textfile as specified, then choose a menu item (limited to 1 - 3 at this time) and play by editing the text file. Type the word you see on the screen as fast as you can (then hit ctrl + s) and type the next word (ctrl+a+del is a useful short cut). I know this interface sucks which is why I will improve it with time (suggestions are more than welcome).
Credit goes to Dason for showing us great new ways of procrastination in R.
Find the code here View attachment 1452
This has only been tested on Linux (PCLOS, e17,R 2.13.0).
As for copyright ect, the code is free for everyone to use and abuse. Give credit where credit is due, or don't- I don't mind as my coding is really is not that impressive (very basic R).
I got a little bored with my static battleship game. I also wanted to know if a way existed to read user input without breaking a loop (I need to do this for something else). So called "non-blocking user input", which is simple in other languages but I had no idea if this could work in R easily. For instance scan, menu, readline all don't have this functionality.
So I thought I might try to crack it by making a clone of a classic dos game. Platform games are too complex but a speed type game should be ideal. However after playing around the only way I can think of to do this (implement "non-blocking user input") is via a connection to a file. So I implement a GUI from e.g. a C++ code, and then type my words in there, which changes the contents of a file.. which can then be read by R. A major pain to say the least. You guys have any ideas on how to implement "non-blocking user input"?
How to play? In this early beta version you will need to open both R and a file editor. Copy & paste the code into R or use source(), then type "typespeed()" and the game should start. You can choose out of 3 libraries (please help me improve these, or add suggestions for your own). Make sure you open the textfile as specified, then choose a menu item (limited to 1 - 3 at this time) and play by editing the text file. Type the word you see on the screen as fast as you can (then hit ctrl + s) and type the next word (ctrl+a+del is a useful short cut). I know this interface sucks which is why I will improve it with time (suggestions are more than welcome).
Credit goes to Dason for showing us great new ways of procrastination in R.
Find the code here View attachment 1452
This has only been tested on Linux (PCLOS, e17,R 2.13.0).
As for copyright ect, the code is free for everyone to use and abuse. Give credit where credit is due, or don't- I don't mind as my coding is really is not that impressive (very basic R).