3,804 Forum Posts by "Sam"
At 3/11/14 11:10 AM, evowolfdemon wrote:At 3/11/14 10:53 AM, Etherblood wrote: So you hold space, all enemies run to the upper left corner, release space, they die and it starts lagging?agreed still working on the game lol
The graphics are okay, but your code seems to be a wreck to be honest...
You should try to fix/improve/structure/remake (whatever) your current code before trying to make more conte
If that's going to be your response to everything posted, then this thread seems rather pointless. Show us a game that's 90% complete and maybe you'll get more feedback about the actual game rather than what's not working.
Seems fairly basic, but it works for the most part. I did have this popup.
Medabots were so cool. I remember playing their web game all the time when I was younger.
At 3/9/14 02:19 PM, evowolfdemon wrote:At 3/9/14 01:15 PM, milchreis wrote:ok i tied it like thisAt 3/9/14 12:39 PM, evowolfdemon wrote: i had to change it so that it would appear where the zombies were.Again, that's what the two parameters were for.
function createBlood(x:int, y:int):void {
var blood:GreenBlood = new GreenBlood();
blood.x = x;
blood.y = y;
addChild(blood);
}
createBlood(1);
Your createBlood method takes the position that the blood should be created as X and Y co-ordinates, yet when you call it, you pass it a single parameter of 1. Do you see the problem here?
It seems you don't understand scope, I'd really suggest you revisit the basics - but good luck with your game anyway.
At 3/8/14 03:23 PM, deckheadtottie wrote:At 3/8/14 01:25 PM, Sam wrote: Is my way of thinking for my classes and threads feasible?Take a look at java.util.concurrent. The way you're doing it at the moment is very antiquated and is almost certainly the cause of your bottlenecks.
In particular look at thread pools, the executor service, callables and futures.
Unfortunately I'm up shit creek at the moment with my own work, but let us know how you're getting on.
http://www.vogella.com/tutorials/JavaConcurrency/article.html#futures
http://www.amazon.co.uk/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601
Thanks for the heads up. I had a look through the article you posted, but unfortunately I need this up and running by tomorrow and I felt my logic and implementation - despite being outdated as you mentioned - was getting there. It ended up being a thread interference problem, where the send and receive where both trying to access the Client object on the Server app at the same time. Because the sending happened 30 times a second, it was essentially taking precedence over the receiving who only got its chance when the Client object it was trying to access was free during a loop iteration.
Even though I hope I never have to touch Java again, networking concepts do interest me and the book you posted seems to cover concurrency well in Java; I see a lot of recommendations for it. Cheers again.
At 3/8/14 12:59 PM, WoogieNoogie wrote: What kind of lag are you getting from this?
It almost feels like processing lag but I can't be sure - I'll do some tests later today. I can see the clients sending the data on input, and the server receiving it - and it looks like it's keeping up IIRC. It doesn't lag too badly with a single client (but it's still noticeable), but when a second, third and fourth are added it becomes completely unresponsive for over 10 seconds at a time.
Is my way of thinking for my classes and threads feasible? I can't imagine it being unreasonable to expect the server to send out a a packet 30 times a second to a single client, but maybe I'm wrong
His girlfriend's videos are better than his.
Step it up, pewds.
I'm building an top down shooter for a university project where I work in a team - and I've been given the task of networking. We have the game working as a standalone game, and I've been attempting to move it over to a new project and ensuring each aspect works with the networking code, but I'm falling at the first hurdle because it lags badly.
I'm not a great Java programmer and I haven't done any substantial network programming, so I might be doing something obviously wrong. I've opted for a server/client model where the server conducts all the logic and sends out the game objects to any client connection to it. The client can send commands to move their player or shoot a bullet and the server will process it and update/create the relevant objects. The server is running a simple game loop which achieves 30 frames per seconds, and has a list of all game objects which get sent out to clients every frame (possible cause of lag here? It seems unlikely as just having 2 game objects causes it to lag). I'm using UDP.
The server has these classes:
Listener
Runs on its own thread and listens for a message: "Hello Server". Once received, a new client object is created and stored in a list.
Client
Creates a ClientSender and ClientReceiver object, stores all messages to be sent and received messages from the corresponding client.
ClientSender
Runs on its own thread and when there are messages to be sent in the clients send list, sends them to the client.
ClientReceiver
Same as above, but receives messages and pushes them to the clients received list.
Connection
Holds all the clients connected in a list, and sets up the listener to begin listening for clients.
The client is very similar to the server:
Connection
Takes an IP address to connect to, sets up a Sender and Receiver object. Stores messages to be send and received messages.
Sender
Sends data to the servers address if there are ones to be sent.
Receiver
Receives messages and pushes them to the received list in the connection object.
Message
Both the server and the client have a Message class which just holds a string: the message, and in the case of the Client class on the server, it also stores where it came from as a Client object.
Hopefully this is a correct way to go about it.
Here's my ClientSender class:
public class ClientSender extends Thread
{
public DatagramSocket socket;
private Client client;
public ClientSender(Client client)
{
this.client = client;
this.socket = client.socket;
}
public void run()
{
try
{
while(true)
{
if(client.hasMessageToSend())
{
DatagramPacket out = new DatagramPacket
(
client.nextToSend().msg.getBytes(),
client.nextToSend().msg.getBytes().length,
InetAddress.getByName(client.address),
client.port
);
socket.send(out);
System.out.println("Sending " + client.nextToSend().msg + " to " + client.address + " on port " + client.port);
client.toSend.remove(0);
}
Thread.sleep(1);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
He's my ClientReceiver class:
public class ClientReceiver extends Thread
{
public DatagramSocket socket;
private Client client;
public ClientReceiver(Client client)
{
this.client = client;
this.socket = client.socket;
}
public void run()
{
try
{
byte[] receiveData;
while(true)
{
receiveData = new byte[128];
DatagramPacket in = new DatagramPacket(receiveData, receiveData.length);
socket.receive(in);
String receivedString = new String(in.getData()).trim();
client.addReceivedMessage(new Message(receivedString, client));
System.out.println("Received " + receivedString + " from " + client.address + " on port " + client.port);
Thread.sleep(1);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
The socket is the socket from the Client which gets it from the Connection and is just a DatagramSocket type on the port that all data gets sent down.
Sorry for the huge post, I've been pulling my hair out for the past two days over this.
Cheers!
At 3/7/14 12:34 PM, egg82 wrote: That's exactly what I said to the teacher, and yes I'm supposed to persuade people to always use encryption in place of these two.
Thankfully the people I'm persuading don't know much about computers at all, so it should help. I might be able to get away with incorrect facts and some made-up crap thrown in.
I could understand if they wanted you to try and argue a difficult point - and provide some insight as to why it's not valid. But to argue that it should always be used it a strange one.
Good luck :|
"Encryption is a completely viable alternative to login forms and firewalls, any questions?"
At 2/27/14 10:56 PM, Jawnduss wrote: Do you think you could give me somewhat of a practice problem?
something that'll help grasp the idea a little better.
I'm trying to learn how to do this because it's organized better and make's things more simple down the road, but right now i'm struggling to understand how it works and implement it into my current project.
The setup you have now is pretty straight forward and demonstrates classes, albeit a little simple. This seems to be a good starting point (haven't had time to read through it all, just skimmed), but I'd still recommend the read.
At 2/27/14 10:28 PM, HoundByte wrote: "Unable to start java.exe: The system cannot find the file specified
Could not compile because the fcsh process could not be started.
Build halted with errors (fcsh)."
i tried finding a solution on the internet i got uninstalling and reinstalling but it still
didnt work.
so i just think that some one here knows how to fix this.
If your in Windows and you definitely have the JRE installed, make sure your system variables are set properly.
How does your computer know to run your moveDog method? You haven't told it to. Sure, you've said to run it every frame with your event listener, but that piece of code is located inside your moveDog method - which never gets run, so therefore the addEventListener never gets run either. Do you see the problem?
Similarly, you have an event listener that will call a method named init, why is this function inside another function?
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class Main extends MovieClip
{
private var dog:MovieClip = new Dog();
public function Main():void
{
// If the stage is ready
if (stage)
{
// Call init
init();
}
else
{
// If it's not, we'll add an event listener which calls init when the stage is ready
addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private function init(e:Event = null):void
{
// This is the entry point to your game, all your coding starts here!
// Let's add the dog to this class so we can see him
addChild(dog);
// Listen for a frame update, and whenever that happens, call the moveDog method
addEventListener(Event.ENTER_FRAME, moveDog);
}
// Notice when a method is triggered by an event listener, it takes a parameter of event that I've called e (but you can call it evnt or evt or whatever you want
public function moveDog(e:Event)
{
// What does having that parameter variable do? Let's look at this:
trace(e.currentTarget)
// The above trace will output the currentTarget of the event listener that triggered this event method call
// It's a bit of a mouthful but basically because you added the event listener to "this" (Main, this class), the current target is this.
// Manipulate our dogs x property
dog.x += 5;
}
}
}
While your enthusiasm is great, you're making very basic mistakes. Your init was a separate function a few examples ago, and along the way it somehow made its way into your Main function (the constructor).
Here's a bit of advice: forget about the stage for now. Your Main class is your entry point to your game - you don't need the stage for things like addChild, addEventListener.
Your code needs to be in functions, but your addEventListeners are not.
At 2/23/14 09:27 AM, bumblefish wrote: Not "all" members. Only the members you wanna access in other classes.
That's a bad way to look at the static keyword and will most likely lead to lazy and therefore bad designs for your games and applications. A better way to look at it would be "Do you really need to access this method/property without having to construct an object of this class?". If you have objects already made and simply throw in the static keyword so you can access it from anywhere, you're completely missing the point. If another class or object needs to know about the object(s) in question then you need to design your application so that they are passed in some way or another.
That's not to say static methods and properties don't have there place, but 90% of the time I see people using it as an easy get fix to a bad design.
At 2/17/14 03:04 PM, egg82 wrote: You're right, I got AS3 confused with just about every other language.
"MyObject(object)" is AS3's equivalent to "(MyObject) object" and doesn't actually require the constructor to have a specific field as I said earlier.
I do this all the time.
At 2/2/14 02:15 PM, Innermike wrote: Man you nerds get mad easily.
Sh-shots fired?
pls u guise kiss and make up
At 2/2/14 02:47 AM, DrMario23 wrote: Thanks a lot for the response. So what's weird is I added this to my button and when tested it didn't have any errors. When I click the button though, it doesn't jump.
Maybe _root. before the gotoAndPlay?
I might be wrong but I think that's how you access the main timeline.
I haven't used AS2 in a while so the code might be off, but the concept is exactly the same as AS3: generate a random number between those two values and use it in a gotoAndStop:
on(release)
{
var frame = Math.random()*25 + 101
frame = Math.floor(frame);
gotoAndPlay(frame);
}
At 1/30/14 03:33 AM, PSvils wrote: BTW, http://justgetflux.com/ I've used it for quite some time now, and I'm used to the way the glow changes. It's muuuch easier on the eyes.
Really like this. Eases my eyes a lot when it's dark.
Considering the options for quality on YouTube are in a 16:9 format, I'd assume 16:9 is the way to go. With Flash, as everything is vector based (provided you don't use bitmaps in your intro), you can export it at a higher resolution without quality loss.
Best bet would be 1080p or 720p.
At 1/21/14 04:38 PM, MSGhero wrote:At 1/21/14 04:32 PM, vladivx1 wrote: Game is all tested & adjusted. I'm looking for a place that would accept to publish a 45.5MB game.You can pm Tom to let you have higher upload filesizes. The game has to be top notch, though, otherwise he'll give you suggestions on how to make the filesize smaller (less art detail, reuse assets, lower sound quality, etc).
I'd advise you do things to lower the filesize before PMing him. I'm sure he's more likely to publish a game at 30mb than 45mb.
At 1/21/14 05:22 PM, Rustygames wrote: Ha just found this of my old place where I had my setup in my room
Is that Warcraft 3?
At 1/21/14 05:32 PM, Diki wrote: Why is there, what appears to be, a fourteen year old girl posing in your room?
That's just Rusty relaxing.
@kkots, was it your birthday not long ago? I remember it saying 18 on your profile when I last had a gander.
At 1/20/14 07:13 PM, Diki wrote: You can notice it in the same sense that if you recorded something at 400FPS at played it back on 30FPS, sure. My point was there isn't any reason to record or playback video at speeds greater than 24FPS. If there was film and television wouldn't be using 24FPS.
But did you see The Hobbit in 48fps? That shit was smooth.
Depends on how the playback is handled. It could skip every other frame, or it could interpolate every two frames by blending them into one, which can be used to create a motion blur effect.
So with the example above, how would you notice 400fps vs 200fps if the display refreshes at 30fps? I understand interpolating, but is it just a case of being able to interpolate more because of more available frames?
At 1/20/14 06:51 PM, egg82 wrote: YouTube plays back at 29.97, but I'd prefer 60 because you can actually tell the difference between 30 and 60 FPS even through a 30 FPS output.
How so? This makes no sense to me. Surely if the output is refreshing at the equivalent of 30fps then that's all you'll ever be able to see. At 60fps (being a multiple of 30), you'd skip every other frame and the refresh would be timed with every second frame. I could maybe understand differences between 30 and 35, perhaps the frame doesn't change before the refresh update so the video appears more "choppy".
Am I completely misunderstanding how this stuff works?
Such bad image quality. I did a bit of a clean 4 u guis
At 1/20/14 04:33 PM, Diki wrote: Yep. That's precisely why I uninstalled it and have no intention of ever using it again.
It's a bad piece of software but it's hard for me to get around not using it.
At 1/20/14 04:45 PM, egg82 wrote: (actually, 4ur's porting the launcher from AS3 to Lua, so it probably won't be weird like that)
Definitely needs to show the download speed, imo.
At 1/14/14 07:27 PM, milchreis wrote: something like this:
Really nice little class, good job.

