Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am making a Star Trek game for Linux in Perl, however the server telling the client it got shot seems to lag. It carries out the info, like decreasing hull integrity, but it does not tell the user all it should. please help!
$Server_connection10=new IO::Socket::INET->new(LocalPort=>2010,Proto=> +"udp"); $battle_accept = threads->new( sub{ while($Server_connection10->recv($text2,10000)){ ($attacked,$attacker,$damage,$nothing) = split("----", $text2); if($attacked =~ m/phasers/i){ if($shields eq "on"){ print"\nWe have been attacked by the $attacker!!"; $shield -= ($damage / 10); $shield10 = $shield * 10; print"Shields are at $shield10!"; if($shield <= 0){ print"\nShields are down!!"; $shields = "off"; } }else{ print"\nWe have been attacked by the $attacker!!"; $hull -= $damage; print"Hull integrity is at $hull!"; if($hull <= 0){ print"YOU HAVE BEEN DESTROYED BY THE $attacker."; $again = 1; $dead = 1; } } }else{ if($shields eq "on"){ print"\nWe have been attacked by the $attacker!!"; $shield -= ($damage / 50); $shield10 = $shield * 10; print"Shields are at $shield10!"; if($shield <= 0){ print"\nShields are down!!"; $shields = "off"; } }else{ print"\nWe have been attacked by the $attacker!!"; $hull -= int($damage * 1.5); print"Hull integrity is at $hull!"; if($hull <= 0){ print"YOU HAVE BEEN DESTROYED BY THE $attacker."; $again = 1; $dead = 1; } } } } } );
This is the thread used for recieving battle commands from the server. I don't want an overhaul of the programming idea, such as a different way to do it instead of a server, I just want to figure out why it is doing this. Thanks in advance, guys!

In reply to My game has problems by AI Cowboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found