Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 29 Aug 2014, 06:30
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
A little C++ app
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
thelaptopkiller

Joined: 25 Oct 2009
Posts: 67
Location: The only place in tornado ally with no tornadoes

PostPosted: Fri 03 Dec 2010, 14:51    Post subject:  A little C++ app
Subject description: For games and computer usage
 

So I have been working on a (not so)simple little program for a few days and wanted to post it here.

It is a little timer app for a online MMOG game called Roblox.

I let some kids use my computer and don't want them to stay on for 2 hours playing it.
(Don't ask why I do it)

So far it is window$ only just because the game only works on window$.
(Pity....)

I have it set as a bat script,a launcher for that bat script and the timer/roblox launcher that fires a log off script.

Here is the code I decided on for the main launcher:
Code:
#include <iostream>
#include <windows.h>
#include <dos.h>
#include <unistd.h>


using namespace std;

int main()
{
cout << "========================================================";
cout << "\n=====================Warning!===========================";
cout << "\n======If you close this program you will log off!=======";
cout << "\n========================================================";
cout << "\n========================================================";
cout << "\n\nWaiting for internet to load...\n";
Sleep(10000);
cout << "Starting Roblox\n";
system("E:\\Roblox.exe");
cout << "\n\n\nYou have 30 minutes before I log you off.";
Sleep(3300000);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
PlaySound("E:\\WINDOWS\\Media\\Windows XP Ringout.wav", NULL, SND_FILENAME|SND_LOOP);
Sleep(300000);
system("E:\\Log_off.bat");
}


Here is the code for the startup launcher:
Code:
#include <iostream>
#include <windows.h>



using namespace std;

int main()
{
system("E:\\Startup.bat.bat");
}



Any comments?

At all?
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4346

PostPosted: Sun 05 Dec 2010, 02:27    Post subject:  

It's pretty simple in Linux (or any *nix for that matter) using a script.

This should let you time any game - just save it as timedgame and call it like:

timedgame Roblox
Code:
#!/bin/sh

echo "======================================"
echo "==================Warning!==============="
echo "======If you close this program you will log off!======="
echo "======================================"
echo "======================================"
echo
##############NOT REALLY DOING ANYTHING - SO COMMENTED
#echo "Waiting for internet to load...";
#sleep 10
##########################################

$1 &
sleep 3300
echo "You only have 5 minutes left"
aplay /usr/share/audio/2barks.wav
sleep 300
aplay /usr/share/audio/leave.wav
killall $1

(note that you will need to be in a terminal to see the echoes ... would be better to use Xdialog, xmessage or yaf-splash etc ... this was just an example)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
thelaptopkiller

Joined: 25 Oct 2009
Posts: 67
Location: The only place in tornado ally with no tornadoes

PostPosted: Fri 10 Dec 2010, 18:50    Post subject:  

And THAT is why I love puppy!

bash is so much easier than C++ for sure
no chance of blowing off my foot with one letter Rolling Eyes

I can't get playsound() to play for over 20 seconds though, what's with that?

if only roblox would work in wine... Sad



TLK
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0507s ][ Queries: 12 (0.0061s) ][ GZIP on ]