Jump to content

Hak5 Graffiti Wall


Recommended Posts

Hey guys, this is the code I whipped together to make the Hak5 Graffiti wall. Toss in a projector and a webcam and it's fun for the whole Internet. Now lets make it even better! :)

Write.php

<?php
if (isset($_POST['name']) && !empty($_POST['name'])) { 
	$nam = stripslashes($_POST['name']);
	$msg = stripslashes($_POST["message"]);
	$nam = htmlspecialchars($nam, ENT_QUOTES);
	$msg = htmlspecialchars($msg, ENT_QUOTES);
	$content = $nam . ": " . $msg;

	//filtering
	$blocked = array("fuck", "shit");
	$replacewith = array("frak", "shazbot");
	$content = str_replace($blocked, $replacewith, $content);

	//write to file to display on wall
	$filed = @fopen("data.txt", "w");
	@fwrite($filed, "$content");
	fclose($filed);

	//write to log
	$filed = @fopen("data.log", "a+");
	@fwrite($filed, "$REMOTE_ADDR $content\n");
	fclose($filed);

	echo "<b>Message Posted $REMOTE_ADDR</b><br /><br />";
}
?>

			<center>
			<form name="Graffiti Wall" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="application/x-www-form-urlencoded">
			Name: <br />
			<input type="text" name="name" size="14"><br><br>

			Message: <br />
			<textarea rows="3" cols="15" name="message"></textarea> <br /><br />

			<input type="submit" value="Write on the Hak5 Wall" name="submit">
			</form></center>

show.php

<?php
$filename = "data.txt";
$whattoread = @fopen($filename, "r");
$file_cnt = fread($whattoread, filesize($filename));
$msg = "$file_cnt";
fclose($whattoread);
?>
<html>
<head>
	<meta http-equiv="refresh" content="7">
</head>
<body bgcolor="#000000" text="#ffffff">
	<div style="font-size:1000%; font-family:courier new; font-weight:bold;">
		<?php echo $msg; ?>
	</div>
</body>
</html>

Suggestions?

Link to comment
Share on other sites

i already suggested a username and account thing. but that would take a long time and you could use something sooner.

so (if this thing is a more perm setup) then why not setup a password system. where you apply via the forums for a password. the you can use the password for each post on the wall. log each post by the password instead of just the name and you could find and ban people from the program by deleting their passwords from the php.

though that might take longer depending on how it would be setup. i dont know for sure since i dont know php (its next on my list after c++)

of course something like that would be a precursor to a login system. or if you could link the forums logins to the wall it might make things easier. but idk if thats even possible.

just throwing in my suggestions. hopefully i sparked a few light bulbs.

edit

and maybe if you can try a code to automatically reduce font based on the size of the message.

Link to comment
Share on other sites

I would suggest that you base this on a database instead (eg. sqlite), and then check that every post is displayed on the wall, because with the current script, two people could post something almost at the same time, and then one of the posts won't be displayed.

But maybe that is wanted, with the benefit of having some updated posts that could comment what was happening on the set, instead of having a 10 minute queue for getting a post shown.

If you want this I could try to put something together...

Edit: Oh btw, it would also be easy to add a validation system to the above solution, so a person has to approve each post before they get into the queue, in order to limit spam and ads.

Edit 2: I just saw the 3x11 episode, and if you want people to post ascii art on the wall, you probably need to enclose the text in <pre> tags, or at least make newlines (\n) into HTML newlines (<br />).

Link to comment
Share on other sites

lil' update...to write.php :rolleyes:

* Smileys

* BBCode

//text to smileys =) 
$content = str_replace(":(","&lt;img src=\"smileys/sad.gif\" alt=\":(\"/&gt;", $content);
$content = str_replace(":(","&lt;img src=\"smileys/sad.gif\" alt=\":(\"/&gt;", $content);
$content = str_replace(";(","&lt;img src=\"smileys/cry.gif\" alt=\";(\"/&gt;", $content);
$content = str_replace(":@","&lt;img src=\"smileys/mad.gif\" alt=\":@\"/&gt;", $content);
$content = ereg_replace(":)","&lt;img src=\"smileys/smile.gif\" alt=\":)\"/&gt;", $content);
$content = ereg_replace("=)","&lt;img src=\"smileys/smile.gif\" alt=\"=)\"/&gt;", $content);
$content = ereg_replace(":D","&lt;img src=\"smileys/laugh.gif\" alt=\":D\"/&gt;", $content);
$content = ereg_replace(":d","&lt;img src=\"smileys/laugh.gif\" alt=\":d\"/&gt;", $content);
$content = ereg_replace(":p","&lt;img src=\"smileys/tongue.gif\" alt=\":p\"/&gt;", $content);
$content = ereg_replace(":P","&lt;img src=\"smileys/tongue.gif\" alt=\":P\"/&gt;", $content);
$content = ereg_replace(":O","&lt;img src=\"smileys/shocked.gif\" alt=\":O\"/&gt;", $content);
$content = ereg_replace(":o","&lt;img src=\"smileys/shocked.gif\" alt=\":o\"/&gt;", $content);
$content = ereg_replace(";)","&lt;img src=\"smileys/wink.gif\" alt=\";)\"/&gt;", $content);
$content = ereg_replace(":S","&lt;img src=\"smileys/sick.gif\" alt=\":S\"/&gt;", $content);
$content = ereg_replace(":s","&lt;img src=\"smileys/sick.gif\" alt=\":s\"/&gt;", $content);
$content = ereg_replace(":roll:","&lt;img src=\"smileys/roll.gif\" alt=\":roll:\"/&gt;", $content);

//bbcode 
$content = str_replace("[B]", "&lt;strong&gt;", $content); 
$content = str_replace("[/B]", "&lt;/strong&gt;", $content); 
$content = str_replace("[I]", "&lt;em&gt;", $content); 
$content = str_replace("[/I]", "&lt;/em&gt;", $content); 
$content = str_replace("[U]", "&lt;u&gt;", $content); 
$content = str_replace("[/U]", "&lt;/u&gt;", $content); 
$content = str_replace("[LI]", "&lt;li&gt;", $content); 
$content = str_replace("[/LI]", "&lt;/li&gt;", $content);

Link to comment
Share on other sites

I would suggest that you base this on a database instead (eg. sqlite), and then check that every post is displayed on the wall, because with the current script, two people could post something almost at the same time, and then one of the posts won't be displayed.

But maybe that is wanted, with the benefit of having some updated posts that could comment what was happening on the set, instead of having a 10 minute queue for getting a post shown.

If you want this I could try to put something together...

Edit: Oh btw, it would also be easy to add a validation system to the above solution, so a person has to approve each post before they get into the queue, in order to limit spam and ads.

Edit 2: I just saw the 3x11 episode, and if you want people to post ascii art on the wall, you probably need to enclose the text in <pre> tags, or at least make newlines (\n) into HTML newlines (<br />).

i dont think setting up a que would be a good idea. im on here with aroujnd 40 osmething people and it takes no more than 2 tries to get my message shown. usually i only have to post once

Link to comment
Share on other sites

i would love to see what someone breaking into your house would do if suddenly the wall said

"i'm watching you put down the damn tv"

ummmm think you could link the wall to maybe an irc log?

at any rate this would be great for the live show.

here. found a problem with the bbcode you had setup. heres a fix

$content = str_replace("[b]", "&lt;strong&gt;", $content);
$content = str_replace("[/b]", "&lt;/strong&gt;", $content);
$content = str_replace("[i]", "&lt;em&gt;", $content);
$content = str_replace("[/i]", "&lt;/em&gt;", $content);
$content = str_replace("[u]", "&lt;u&gt;", $content);
$content = str_replace("[/u]", "&lt;/u&gt;", $content);
$content = str_replace("[li]", "&lt;li&gt;", $content);
$content = str_replace("[/li]", "&lt;/li&gt;", $content);

it wasn't taking lower case letters. i dont know php but i have enough reasoning skills to alter some code

Link to comment
Share on other sites

Might i suggest this for the name input tag in write.php:

&lt;input type="text" name="name" size="14" value="&lt;?php echo $nam; ?&gt;"&gt;

that way it 'saves' your name after you 'write on the hak5 wall', you might be able to do it this way "<?=$nam?>" but it doesn't work on my webserver...

edit-

you should probably add some more words to the "blocked" list....

Link to comment
Share on other sites

the "please wait" thing when your the last person to post could be timed. which would make it easier to mess with when there aren't many people typing

for those that want to mess with it heres a bit of fun info

20 periods will make a new line. although because of the lack of a word wrap on single words you could type 300 unspaced periods and it would only do 1 line.

then 2 periods to reach the window.

dont forget to account for your name.

ill keep messing with it and maybe we can have some cool stuff.

for me(because i only accounted for my name) this will print the text over the window. although 1 letter on last line is off of it. and one more line will be off of it.

.........
.....................
..check......................
..the........................
..forums...............................
..4details.................

this will print on the window without overlap

.........
........................
..iR......................
..window.................
..iR.......................
..ruler!................

Link to comment
Share on other sites

Here's a few functions I threw together that might improve it a little.

&lt;?php

//LENGTHANDWRAP - cuts length, wraps and builds content
function LengthAndWrap( $name, $message )
{
    //SETTINGS
    define("MESSAGE_MAX_LENGTH", 150);
    define("MAX_WRAP_LENGTH", 18);
    
    //BUILD STRING
    $string = $name . ": " . $message;
    
    //TRIM LENGTH
    $string = substr( $string, 0, MESSAGE_MAX_LENGTH );
    
    //WRAP
    $string = wordwrap($string, MAX_WRAP_LENGTH, "&lt;br /&gt;", true);
     
    //RETURN
    return $string;
}



//CENSOR INPUT - removes bad parts of string
function CensorInput( $input )
{
    //======================================================//
    // Reads text file in the format: FIND:REPLACEWITH;
    // Example:
    // fuck:sunshinedust;
    // dick:willy;
    // pussy:lady area;
    // balls:face;
    //======================================================//
    
    
    //SETTINGS
    define("WORD_FILE", "words.txt"); //bad word file
    
    //GET LIST OF WORDS
    $handle = fopen( WORD_FILE, "r" );
    $string = fread($handle, filesize( WORD_FILE ));
    fclose($handle);

    //REMOVE WHIE SPACE
    $string = str_replace("\r\n", "", $string);//remove CRLF
    $string = trim( $string ); //trim other whitespace
    
    //PREP FOR LOOP
    $total = substr_count( $string, "="); //count number of word replacements
    $curr = 0;
    $end = 0;
    
    //PARSE CENSOR FILE
    while ($curr != $total)//while the current divider is not the same as the total dividers
    {
    
        //GRAB WORD TO REPLACE
        $start = ($end!=0?$end+1:0); //set to 0 if its the start of the file else +1
        $end = strpos($string, "=", $start); 
        $bad = substr( $string, $start, $end-$start );
    
        //GRAB REPLACEMENT
        $start = $end + 1;
        $end = strpos($string, ";", $start);
        $good = substr( $string, $start, $end-$start);
    
        //UPDATE ARRAYS
        $replacements[] = $good;
        $WordsOfTheDevil[] = $bad;
    
        //MOVE ALONG STRING
        $curr++;
    }
    
    //CENSOR
    $input = str_ireplace( $WordsOfTheDevil, $replacements, $input ); //replace, with, in

    return $input;
}
?&gt;

Link to comment
Share on other sites

I Think it would be better if it just showed the last 2-5 lines from like #wall in mintirc.net

Im sure the php-irc framework could handle it, and there are a few people in the community that are pretty good with that (cough the_php_jedi cough). Though some AJAX would probably be better...

Link to comment
Share on other sites

Hey guys thanks for all the feedback. I'm wanting to add more features faster than I can keep up. I'd really like to add your code into the mix as well as toss in some fun stuff like maybe simple multiplayer games but I'm leaving for Toronto tonight and won't return until Monday. I'll check in to make sure everything is running smoothly periodically.

I want to first bring attention to the awesome Adobe Air Setcam app, it totally rocks my socks. http://hak5.org/forums/index.php?showtopic=9526

Also, thanks to SomeoneE1se the code has been much improved so I'm pasting the latest version here. Feel free to run your own local copy to test features. I built this initially using recycled code from a project I used to run called "6" with WAMP, which I like a lot better than XAMPP on Win.

At first I wanted the wall to support spaces and linebreaks which would make ASCII art easier but at the same time I want it to be friendly to newcomers who are probably expecting it to wordwrap.

Anyway, the code:

Write.php

&lt;?php
if (isset($_POST['name']) &amp;&amp; !empty($_POST['name'])) {

$imploder = 'sdf93jdfe873ifjaj489fb397fgdkw38372brlksuc8934uf8ws6gfk34hv7wbt394ap';
$blocked = array(
"fuck", 
"Fuck", 
"FUCK", 
"shit", 
"Shit", 
"SHIT", 
"cunt", 
"Cunt", 
"CUNT", 
"gonna give you up"
);

$replacewith = array(
"frak", 
"frak", 
"frak", 
"shazbot", 
"shazbot", 
"shazbot", 
"cookie", 
"cookie", 
"cookie", 
"gonna rickroll the hakwall. That would be lame."
);

$name = str_replace($blocked, $replacewith, stripslashes(htmlentities($_POST['name'])));
$msg = str_replace($blocked, $replacewith, stripslashes(htmlentities($_POST['message'])));

$check = file_get_contents('ip.ip');

//Check ban list
if ($_SERVER['REMOTE_ADDR'] == "REMOVED FOR OBVIOUS REASONS" || $_SERVER['REMOTE_ADDR'] == "REMOVED FOR OBVIOUS REASONS" || $_SERVER['REMOTE_ADDR'] == "REMOVED FOR OBVIOUS REASONS" || $_SERVER['REMOTE_ADDR'] == "REMOVED FOR OBVIOUS REASONS" || $_SERVER['REMOTE_ADDR'] == "REMOVED FOR OBVIOUS REASONS" || $_SERVER['REMOTE_ADDR'] == "REMOVED FOR OBVIOUS REASONS") {
	die('You have been banned for being lame. Come back when you grow up.'); }

//Check spam user
if($check &amp;&amp; $check != $_SERVER['REMOTE_ADDR']){

//text to smileys =)
$msg = str_replace(":(","&lt;img src=\"smileys/sad.gif\" width=\"120\" height=\"120\" alt=\":(\"/&gt;", $msg);
$msg = str_replace(":(","&lt;img src=\"smileys/sad.gif\" width=\"120\" height=\"120\" alt=\":(\"/&gt;", $msg);
$msg = str_replace(";(","&lt;img src=\"smileys/cry.gif\" width=\"120\" height=\"120\" alt=\";(\"/&gt;", $msg);
$msg = str_replace(":@","&lt;img src=\"smileys/mad.gif\" width=\"120\" height=\"120\" alt=\":@\"/&gt;", $msg);
$msg = ereg_replace(":)","&lt;img src=\"smileys/smile.gif\" width=\"120\" height=\"120\" alt=\":)\"/&gt;", $msg);
$msg = ereg_replace("=)","&lt;img src=\"smileys/smile.gif\" width=\"120\" height=\"120\" alt=\"=)\"/&gt;", $msg);
$msg = ereg_replace(":D","&lt;img src=\"smileys/laugh.gif\" width=\"120\" height=\"120\" alt=\":D\"/&gt;", $msg);
$msg = ereg_replace(":d","&lt;img src=\"smileys/laugh.gif\" width=\"120\" height=\"120\" alt=\":d\"/&gt;", $msg);
$msg = ereg_replace(":p","&lt;img src=\"smileys/tongue.gif\" width=\"120\" height=\"120\" alt=\":p\"/&gt;", $msg);
$msg = ereg_replace(":P","&lt;img src=\"smileys/tongue.gif\" width=\"120\" height=\"120\" alt=\":P\"/&gt;", $msg);
$msg = ereg_replace(":O","&lt;img src=\"smileys/shocked.gif\" width=\"120\" height=\"120\" alt=\":O\"/&gt;", $msg);
$msg = ereg_replace(":o","&lt;img src=\"smileys/shocked.gif\" width=\"120\" height=\"120\" alt=\":o\"/&gt;", $msg);
$msg = ereg_replace(";)","&lt;img src=\"smileys/wink.gif\" width=\"120\" height=\"120\" alt=\";)\"/&gt;", $msg);
$msg = ereg_replace(":S","&lt;img src=\"smileys/sick.gif\" width=\"120\" height=\"120\" alt=\":S\"/&gt;", $msg);
$msg = ereg_replace(":s","&lt;img src=\"smileys/sick.gif\" width=\"120\" height=\"120\" alt=\":s\"/&gt;", $msg);
$msg = ereg_replace(":roll:","&lt;img src=\"smileys/roll.gif\" width=\"120\" height=\"120\" alt=\":roll:\"/&gt;", $msg);

//BB Code
$msg = str_replace("", "&lt;strong&gt;", $msg);
$msg = str_replace("", "&lt;/strong&gt;", $msg);
$msg = str_replace("", "&lt;em&gt;", $msg);
$msg = str_replace("", "&lt;/em&gt;", $msg);
$msg = str_replace("", "&lt;u&gt;", $msg);
$msg = str_replace("", "&lt;/u&gt;", $msg);
$msg = str_replace("[LI]", "&lt;li&gt;", $msg);
$msg = str_replace("[/LI]", "&lt;/li&gt;", $msg);

$msg = str_replace("", "&lt;strong&gt;", $msg );
$msg = str_replace("", "&lt;/strong&gt;", $msg );
$msg = str_replace("", "&lt;em&gt;", $msg );
$msg = str_replace("", "&lt;/em&gt;", $msg );
$msg = str_replace("", "&lt;u&gt;", $msg );
$msg = str_replace("", "&lt;/u&gt;", $msg );
$msg = str_replace("[li]", "&lt;li&gt;", $msg );
$msg = str_replace("[/li]", "&lt;/li&gt;", $msg );



	$file = @fopen("UNIQUE TEXT FILE.TXT", "w") or die('Write Error!');
	@fwrite($file, $_SERVER['REMOTE_ADDR'].$imploder.$name.$imploder.$msg);
	fclose($file);

	$fileIP = @fopen("ip.ip", "w") or die('Write Error!!');
	@fwrite($fileIP, $_SERVER['REMOTE_ADDR']);
	fclose($fileIP);

	$filed = @fopen("UNIQUE LOG FILE.LOG", "a+") or die('Write Error!!!');
	@fwrite($filed, $_SERVER['REMOTE_ADDR'] . '	' . $name . ' ' . $msg . "\n");
	fclose($filed);

	echo "&lt;b&gt;Message Posted ". $_SERVER['REMOTE_ADDR'] . "&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;";

} else {
	echo "&lt;b&gt;Please Wait!&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;";
}
}
?&gt;
&lt;center&gt;
&lt;form name="Graffiti Wall" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post" enctype="application/x-www-form-urlencoded"&gt;
Name: &lt;br /&gt;
&lt;input type="text" name="name" size="14"&gt;&lt;br&gt;&lt;br&gt;

Message: &lt;br /&gt;
&lt;textarea rows="3" cols="15" name="message"&gt;&lt;/textarea&gt; &lt;br /&gt;&lt;br /&gt;

&lt;input type="submit" value="Write on the Hak5 Wall" name="submit"&gt;
&lt;/form&gt;&lt;/center&gt;

show.php

&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="refresh" content="4"&gt;
&lt;/head&gt;
&lt;body bgcolor="#000000" text="#ffffff"&gt;
&lt;div style="font-size:700%; font-family:courier new; font-weight:bold;"&gt;&lt;?php
$file = file_get_contents('UNIQUE TEXT FILE');
if($file){
	$data = explode('sdf93jdfe873ifjaj489fb397fgdkw38372brlksuc8934uf8ws6gfk34hv7wbt394ap', $file, 3);
	if($_SESSION['ip'] != $data[0]){
		echo $data[1] . ": \n" . $data[2];
			$_SESSION['ip'] = $data[0];
			$_SESSION['name'] = $data[1];
			$_SESSION['msg'] = $data[2];
	} else {
		echo $_SESSION['name'] . ': \n' .  $_SESSION['msg'];
	}	
} else {
	die('File Access Error!');
}
?&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

I've replaced sensitive data in the code above. Kinda forgot to last time and, well, some of you found the log file ;)

Okies I'll check in when I can over the weekend. Have fun guys and I'll post pics from PurePwnage in Toronto when I get back. Cheers!

PS: links on the setcam page to this thread, the adobe air app, and the privacy policy were added.

Link to comment
Share on other sites

I'd really like to add your code into the mix as well as toss in some fun stuff like maybe simple multiplayer games but I'm leaving for Toronto tonight and won't return until Monday.

A hangman game would be cool :D

Link to comment
Share on other sites

Is there going to be an offline archive of the wall? Not video, but just the text saved somewhere to go back and read funny comments from, etc.

Link to comment
Share on other sites

Hey Darren why not a project similar this in the future for around certain restricted areas of the hak5 house...possibilities are endless.

http://www.bpexplorer.com.au/

essentially drive around a robot equipped with a web cam remotely from a web page...people register and queue up for a go.

maybe just a pipe dream but it could be cool.

Link to comment
Share on other sites

Hey guys, I'm lovin' the graffiti wall (even though it's more like the Graffitivision now.)

I went ahead and hacked together a script in python to let folks run something similar on their own machines.

You need:

Python

PyGame

#import and initialize
import pygame
pygame.init()

class Message(pygame.sprite.Sprite):
  def __init__(self, filename):
    pygame.sprite.Sprite.__init__(self)
    self.font = pygame.font.SysFont("Verdana", 36)
    self.filename = filename    
    in_file = open(self.filename, "r")
    filetext = in_file.read()
    in_file.close()
        
    self.text = filetext
    self.image = self.font.render(self.text, 1, (255, 255, 255))
    self.rect = self.image.get_rect()

  def rendertext(self, font, text, pos=(0,0), color=(255,255,255), bg=(0,0,0)):
      lines = text.splitlines()
      #first we need to find image size...
      width = height = 0
      for l in lines:
          width = max(width, font.size(l)[0])
          height += font.get_linesize()
      #create 8bit image for non-aa text..
      img = pygame.Surface((width, height), 0, 8)
      img.set_palette([(0,0,0), (255,255,255)])
      #render each line
      height = 0
      for l in lines:
       t = font.render(l, 1, (255,255,255), (0,0,0))
       img.blit(t, (0, height))
       height += font.get_linesize()
      return img

  def update(self):
    #-----Read text from text.txt----#
    in_file = open(self.filename, "r")
    filetext = in_file.read()
    in_file.close()
            
    self.text = filetext
    #self.image = self.font.render(self.text, 1, (255, 255, 255))   
    self.image = self.rendertext(self.font, self.text)
    self.rect = self.image.get_rect()
    label.rect.centerx = background.get_rect().centerx
    label.rect.centery = background.get_rect().centery


#display
screen = pygame.display.set_mode((800, 600), pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.SWSURFACE)
FULLSCREEN = True

#Entities
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((0, 0, 0))
label = Message("test.txt")
labelSprite = pygame.sprite.Group(label)

#Action
#  Assign vals to vars
clock = pygame.time.Clock()
keepGoing = True

#  Loop
while keepGoing:
  
  #T - Timer for framerate
  clock.tick(30)

  #E - Events
  for event in pygame.event.get():
    if event.type == pygame.QUIT:
      keepGoing = False
    elif event.type == pygame.KEYDOWN:
      if event.key == pygame.K_ESCAPE:
        keepGoing = False
      elif event.key == pygame.K_f:
        if FULLSCREEN:
          screen = pygame.display.set_mode((800, 600), pygame.DOUBLEBUF | pygame.SWSURFACE)
          background = pygame.Surface(screen.get_size())
          background = background.convert()
          background.fill((0, 0, 0))
          label = Message("test.txt")
          labelSprite = pygame.sprite.Group(label)
        else:
          screen = pygame.display.set_mode((800, 600), pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.SWSURFACE)
          background = pygame.Surface(screen.get_size())
          background = background.convert()
          background.fill((0, 0, 0))
          label = Message("test.txt")
          labelSprite = pygame.sprite.Group(label)

        FULLSCREEN = not FULLSCREEN
        screen = pygame.display.get_surface()


  #R - Refresh display
  screen.blit(background, (0, 0))
  labelSprite.update()
  labelSprite.draw(screen)
  pygame.display.flip()

Can't take credit for quite everything, as I had to creatively Google to find that rendertext function that I dropped in the Message class (Why the heck doesn't pygame.font.Font.render support newline chars?) but the rest is mine. :)

Note that this reads from a file "test.txt" in the same directory as the script itself...still working on checking for existence and creating if non-existent file.

EDIT: Had to update a few things: the Python was erroring out on Windows (I have to reinitialize each surface each time I reinitialize the screen...)

Also set the font to "Verdana" because I know every Windows user will have it, and (almost) every Linux user will default to the much prettier FreeSans if they don't have it....

I can zip up a py2exe, if anyone wants it for "drop-in-and-go"

Link to comment
Share on other sites

And a pair of bash functions for dropping in your .bashrc (assuming you're running on Linux)

function writeScreen()
{
echo "$@" &gt; ~/test.txt
}

function writeScreenln()
{
echo "$@" &gt;&gt; ~/test.txt
}

These again assume a file (this time in the home dir) called test.txt. You may need to change this path as necessary. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...