Computer Science Canada NET GAME |
Author: | paulkwatyra [ Sun Nov 20, 2005 3:11 pm ] |
Post subject: | NET GAME |
Hey pplz k im new at turing and i have made a game very simple %%%%%%%%%%%%%%%%%%%%%%%%% var chars,chars2:array char of boolean var x,y,x2,y2:int x := 250 y := 200 x2 := 400 y2 := 400 loop Input.KeyDown (chars) if chars (KEY_UP_ARROW) then %player one movement up% y := y + 10 end if if chars (KEY_RIGHT_ARROW) then %right% x := x + 10 end if if chars (KEY_LEFT_ARROW) then %left% x := x - 10 end if if chars (KEY_DOWN_ARROW) then %down% y := y - 10 end if Draw.FillOval (x, y, 4, 4, 13) Input.KeyDown (chars2) if chars2 ('w') then %player two movement up% y2 := y2 + 10 end if if chars2 ('d') then %right% x2 := x2 + 10 end if if chars2 ('a') then %left% x2 := x2 - 10 end if if chars2 ('s') then %down% y2 := y2 - 10 end if Draw.FillOval (x2, y2, 4, 4, 60) delay (20) cls end loop %%%%%%%%%%%%%%%%%%%%%%% and i thought to myself i would like to make it a network game where one person can play from his computer and the other from his, and i have NO clue how to do that im somewhat familiar with opening a network however i dont understand how to transfer info from the ball variables that are moving HELP WOULD BE GREAT |
Author: | [Gandalf] [ Sun Nov 20, 2005 6:10 pm ] |
Post subject: | |
Please don't double post, especially topics. Look in the tutorials section for help before posting here, as it happens, we have a .NET tutorial: Turing Walkthrough - http://www.compsci.ca/v2/viewtopic.php?t=8808 .NET tutorial - http://www.compsci.ca/v2/viewtopic.php?t=5795 |
Author: | Mr. T [ Sun Nov 20, 2005 7:30 pm ] |
Post subject: | Re: NET GAME |
paulkwatyra wrote: and i thought to myself i would like to make it a network game where one person can play from his computer and the other from his, and i have NO clue how to do that im somewhat familiar with opening a network however i dont understand how to transfer info from the ball variables that are moving HELP WOULD BE GREAT
I think it's best if you learn the basics before getting into the more intricate elements of programming. |
Author: | paulkwatyra [ Sun Nov 20, 2005 8:55 pm ] |
Post subject: | |
i do know programming i just dont understand how networks work in turing |
Author: | Cervantes [ Sun Nov 20, 2005 9:03 pm ] |
Post subject: | |
paulkwatyra wrote: i do know programming i just dont understand how networks work in turing
If you were about ready to learn about networking, you'd have a View.Update in there (not that that's related to networking, but it is basic). You'd only be using one array char of boolean (again, not that it's related...). You'd be using a coordinate variable type. I suggest you use the Turing Walkthrough to work your way towards networking. |
Author: | paulkwatyra [ Sun Nov 20, 2005 9:09 pm ] |
Post subject: | |
I completed the rest of my game today and i need to know how to network it i am posting the game for some help so if neone can help me that'll be great, plz dont take ne parts from game. Also note this game is still in the finishing stage so there are some bugs as i still have a week to finish it for my project at skool [code] var bomb : array 1 .. 4000 of boolean var bombx : array 1 .. 4000 of int var bomby : array 1 .. 4000 of int var bomb2 : array 1 .. 4000 of boolean var bomb2x : array 1 .. 4000 of int var bomb2y : array 1 .. 4000 of int var i, y, i2, y2 : int var chars : array char of boolean var chars2 : array char of boolean var bombcounter1 : int var bombcounter2 : int var player1dead : boolean var player2dead : boolean var laser : int var laser2 : int i := 500 y := 500 i2 := 100 y2 := 100 for x : 1 .. 4000 bomb (x) := false end for for x : 1 .. 4000 bomb2 (x) := false end for bombcounter1 := 0 bombcounter2 := 0 player1dead := false player2dead := false laser := 60 laser2 := 60 procedure createballs () Draw.FillOval (200, 200, 4, 4, white) Draw.FillOval (400, 250, 4, 4, white) Draw.FillOval (100, 270, 4, 4, white) Draw.FillOval (300, 210, 4, 4, white) Draw.FillOval (400, 100, 4, 4, white) Draw.FillOval (300, 250, 4, 4, white) Draw.FillOval (200, 370, 4, 4, white) Draw.FillOval (100, 410, 4, 4, white) Draw.FillOval (110, 210, 4, 4, white) Draw.FillOval (220, 220, 4, 4, white) Draw.FillOval (330, 240, 4, 4, white) Draw.FillOval (440, 250, 4, 4, white) Draw.FillOval (550, 170, 4, 4, white) Draw.FillOval (101, 280, 4, 4, white) Draw.FillOval (202, 390, 4, 4, white) Draw.FillOval (304, 420, 4, 4, white) end createballs View.Set ("graphics:max;max") colorback (black) cls setscreen ("offscreenonly") loop color (white) put "Amount Laser left :", laser color (brightgreen) put "Amount Laser Left :", laser2 Input.KeyDown (chars) if chars ('j') and chars (KEY_UP_ARROW) and laser > 0 then Draw.DashedLine (i, y, i, maxy, drawDash, brightred) laser := laser - 1 if i = i2 and y < y2 then player2dead := true end if elsif chars ('j') and chars (KEY_RIGHT_ARROW) and laser > 0 then Draw.DashedLine (i, y, maxx, y, drawDash, brightred) laser := laser - 1 if y = y2 and i < i2 then player2dead := true end if elsif chars ('j') and chars (KEY_LEFT_ARROW) and laser > 0 then Draw.DashedLine (i, y, 0, y, drawDash, brightred) laser := laser - 1 if y = y2 and i > i2 then player2dead := true end if elsif chars ('j') and chars (KEY_DOWN_ARROW) and laser > 0 then Draw.DashedLine (i, y, i, 0, drawDash, brightred) laser := laser - 1 if i = i2 and y > y2 then player2dead := true end if end if if chars (KEY_UP_ARROW) and y + 10 < maxy then Draw.FillOval (i, y, 4, 4, black) y := y + 10 end if if chars (KEY_RIGHT_ARROW) and i < maxx then Draw.FillOval (i, y, 4, 4, black) i := i + 10 end if if chars (KEY_LEFT_ARROW) and i > 0 then Draw.FillOval (i, y, 4, 4, black) i := i - 10 end if if chars (KEY_DOWN_ARROW) and y > 0 then Draw.FillOval (i, y, 4, 4, black) y := y - 10 end if if chars ('k') and bombcounter1 < 4000 then bombcounter1 := bombcounter1 + 1 bombx (bombcounter1) := i bomby (bombcounter1) := y bomb (bombcounter1) := true end if if chars ('p') then createballs () end if if chars ('o') then i := Rand.Int (1, 60) * 10 y := Rand.Int (1, 60) * 10 end if if chars ('l') then Draw.FillOval (Rand.Int (1, 600), Rand.Int (1, 600), 4, 4, white) Draw.FillOval (Rand.Int (1, 600), Rand.Int (1, 600), 4, 4, white) Draw.FillOval (Rand.Int (1, 600), Rand.Int (1, 600), 4, 4, white) Draw.FillOval (Rand.Int (1, 600), Rand.Int (1, 600), 4, 4, white) end if Draw.FillOval (i, y, 4, 4, white) if chars ('u') then Draw.FillOval (i, y, 4, 4, black) end if for x : 1 .. 4000 if bomb (x) then Draw.FillOval (bombx (x), bomby (x), 4, 4, white) end if end for if chars ('e') and chars (KEY_UP_ARROW) and laser > 0 then Draw.DashedLine (i, y, i, maxy, drawDash, brightred) laser2 := laser2 - 1 if i = i2 and y < y2 then player1dead := true end if elsif chars ('e') and chars (KEY_RIGHT_ARROW) and laser2 > 0 then Draw.DashedLine (i2, y2, maxx, y2, drawDash, brightred) laser2 := laser2 - 1 if y2 = y and i2 < i then player1dead := true end if elsif chars ('e') and chars (KEY_LEFT_ARROW) and laser2 > 0 then Draw.DashedLine (i2, y2, 0, y2, drawDash, brightred) laser2 := laser2 - 1 if y2 = y and i2 > i then player1dead := true end if elsif chars ('e') and chars (KEY_DOWN_ARROW) and laser > 0 then Draw.DashedLine (i2, y2, i2, 0, drawDash, brightred) laser2 := laser2 - 1 if i2 = i and y2 > y then player1dead := true end if end if if chars ('w') and y2 + 10 < maxy then Draw.FillOval (i2, y2, 4, 4, black) y2 := y2 + 10 end if if chars ('d') and i2 < maxx then Draw.FillOval (i2, y2, 4, 4, black) i2 := i2 + 10 end if if chars ('a') and i2 > 0 then Draw.FillOval (i2, y2, 4, 4, black) i2 := i2 - 10 end if if chars ('s') and y2 > 0 then Draw.FillOval (i2, y2, 4, 4, black) y2 := y2 - 10 end if if chars ('q') and bombcounter2 < 4000 then bombcounter2 := bombcounter2 + 1 bomb2x (bombcounter2) := i2 bomb2y (bombcounter2) := y2 bomb2 (bombcounter2) := true end if for x : 1 .. 4000 if bomb2 (x) then Draw.FillOval (bomb2x (x), bomb2y (x), 4, 4, brightgreen) end if end for Draw.FillOval (i2, y2, 4, 4, brightgreen) View.Update delay (20) cls for x : 1 .. bombcounter2 if i = bomb2x (x) and y = bomb2y (x) and bomb2 (x) then color (yellow) put "Player 1 hits bomb Player 2 wins" player1dead := true exit end if end for for x : 1 .. bombcounter1 if i2 = bombx (x) and y2 = bomby (x) and bomb (x) then color (yellow) put "Player 2 hits bomb Player 1 Wins" player2dead := true exit end if end for exit when player1dead = true or player2dead = true end loop[/color] [/code] THANX A LOT |
Author: | md [ Sun Nov 20, 2005 9:16 pm ] |
Post subject: | |
I sugest you learn a lot more about types (records?), procdures, and functions before you even think of trying to do anything with the network. Networking is an advanced topic, whch required a very good knowledge of the basic principles of good programming. Your code shows that you don't even understand the basics. That's not to insult you or anything, just point out that you're trying to do something that is far beyond your abilities; a much better idea right now would be to take the code you posed and re-write it using types and functions. If you can get that done and understand it (and know why it's better) then you might be able to handle some networking. |
Author: | paulkwatyra [ Sun Nov 20, 2005 9:25 pm ] |
Post subject: | |
alright good idea thanx a lot |
Author: | Mr. T [ Sun Nov 20, 2005 10:33 pm ] |
Post subject: | Alex's Opinion |
paulkwatyra wrote: Hey pplz k im new at turing and i have made a game very simple
paulkwatyra wrote: i do know programming i just dont understand how networks work in turing
Maybe I misunderstood your first statement. |
Author: | Tony [ Sun Nov 20, 2005 10:56 pm ] |
Post subject: | Re: Alex's Opinion |
Pwned wrote: paulkwatyra wrote: Hey pplz k im new at turing and i have made a game very simple
paulkwatyra wrote: i do know programming i just dont understand how networks work in turing
Maybe I misunderstood your first statement. I seem to be misunderstanding a lot of things.. from another post paulkwatyra wrote: ok so im pretty good with the entire turing language and i want to learn a new one |
Author: | Mr. T [ Sun Nov 20, 2005 11:27 pm ] |
Post subject: | Alex's Opinion |
paulkwatyra wrote: ok so im pretty good with the entire turing language and i want to learn a new one... i am new at programming tho as i just learned turing this year
Quite the hypocrite, indeed. |
Author: | MysticVegeta [ Sun Nov 20, 2005 11:47 pm ] |
Post subject: | |
Come on Come on guys! Lets not forget, people will do anything for help, and the opposite of that thing to get ahead, I find this guy smart, maybe he should take a break from programming and do some business! sarcasm intended |
Author: | [Gandalf] [ Mon Nov 21, 2005 1:50 am ] |
Post subject: | Re: Alex's Opinion |
Pwned wrote: paulkwatyra wrote: ok so im pretty good with the entire turing language and i want to learn a new one... i am new at programming tho as i just learned turing this year
Quite the hypocrite, indeed. Maybe he just thinks he can master Turing and the basics of programming in a day? ![]() |
Author: | paulkwatyra [ Mon Nov 21, 2005 8:17 am ] |
Post subject: | |
not in a day a few months im just getting bored with all the things we learn in skcool |
Author: | ZeroPaladn [ Mon Nov 21, 2005 9:53 am ] |
Post subject: | |
ive been working at turing for 3 years now, and i havent even started learning about net with turing. if you think that you can learn an entire programming language in a few months then you got something coming for ya. take it easy, and learn new things, like cervantes said. i will admit this is a neat game though. |
Author: | paulkwatyra [ Mon Nov 21, 2005 10:04 am ] |
Post subject: | |
if it took you 3 years to learn turing u shouldnt be on this website |
Author: | ZeroPaladn [ Mon Nov 21, 2005 10:10 am ] |
Post subject: | |
was that a flame? i sure hope it wasnt. either way, i took my time and didnt rush myself, mainly because i have the memory of a goldfish. Besides from the point, i know what i know today BY HEART because i took my time, and i think you should do the same. |
Author: | paulkwatyra [ Mon Nov 21, 2005 10:16 am ] |
Post subject: | |
taking 3 years is a hell of a lot of time especially for a simple language like turing |
Author: | Tony [ Mon Nov 21, 2005 10:40 am ] |
Post subject: | |
paulkwatyra wrote: taking 3 years is a hell of a lot of time especially for a simple language like turing
You have one week to write a 3D Engine, and put together a demo. Go! |
Author: | paulkwatyra [ Mon Nov 21, 2005 11:44 am ] |
Post subject: | |
ok who do i send it to? |
Author: | Tony [ Mon Nov 21, 2005 11:49 am ] |
Post subject: | |
you post it up in [Turing SC] |
Author: | MysticVegeta [ Mon Nov 21, 2005 2:47 pm ] |
Post subject: | |
ZeroPaladn wrote: ive been working at turing for 3 years now, and i havent even started learning about net with turing. if you think that you can learn an entire programming language in a few months then you got something coming for ya. take it easy, and learn new things, like cervantes said.
i will admit this is a neat game though. Did you say 3 years? I found a January 2005 post by you called "My First Program" http://www.compsci.ca/v2/viewtopic.php?t=9226 are you sure? |
Author: | SnoopDuck [ Mon Nov 21, 2005 3:27 pm ] |
Post subject: | |
Whats with the fighting people..... Pauls just trying to get some help im in school with the guy and he's freally into his game making you don't gotta get all mad and stuff just point him in the right direction and chill..... |
Author: | Cervantes [ Mon Nov 21, 2005 3:51 pm ] |
Post subject: | |
paulkwatyra wrote: if it took you 3 years to learn turing u shouldnt be on this website
You're not one to say who should be on this site and who should not. This website is open to anyone, provided they follow certain rules. SnoopDuck wrote: Whats with the fighting people..... Pauls just trying to get some help im in school with the guy and he's freally into his game making you don't gotta get all mad and stuff just point him in the right direction and chill.....
It's hard to know what direction to point him in when he reveals his current programming ability in riddles and contradictions. |
Author: | SnoopDuck [ Mon Nov 21, 2005 3:54 pm ] |
Post subject: | |
Maybe to you but..... you can just say hey look up "this" and "this" and that should help you out..... He told you exacly what he needed all you gotta tell him is what he needs, |
Author: | Dan [ Mon Nov 21, 2005 5:11 pm ] |
Post subject: | |
SnoopDuck wrote: Maybe to you but..... you can just say hey look up "this" and "this" and that should help you out..... He told you exacly what he needed all you gotta tell him is what he needs,
Users here just do not like being liyed to. If you look at the 1st few posts there aucatly was some helpfull links posted. I whould ask that users drop the topic of the user progaming level and just assum what they side in this topic is ture. |
Author: | paulkwatyra [ Tue Nov 22, 2005 8:53 am ] |
Post subject: | |
ok... i still dont get how to do networking in the game/???? your net tutorial is horrible it doesnt explain it all it is, is a source code i need to know how to do it.??? so still i need hellp ppl n snoopdog who r u???? |
Author: | Tony [ Tue Nov 22, 2005 9:20 am ] |
Post subject: | |
alright alright, lets take this a bit slower.. what don't you know how to do? An approximate order of steps is as follows: start a server listen to connection start a client request connection to the server connect to the server have a server listen to the next connection (if required) send data to the server about the state of game in each client forward the data to every other active client syncronize states between clients (optional) validate How far can you get in that list? |
Author: | paulkwatyra [ Tue Nov 22, 2005 9:51 am ] | ||
Post subject: | |||
start a server i have the computers connected with the network, the only thing is they arent sending information to each other. here look at this game i made it really simple to try and figure out how to do it.
|
Author: | ZeroPaladn [ Tue Nov 22, 2005 10:18 am ] |
Post subject: | |
lolz, my first program by myself, i started lerning turing in grade 9, and i made programs there but i never tried to make one myself. I make that circle program, and i felt proud ( even though it sucked ![]() oh, and thanks for sticking up for me guys. |
Author: | Tony [ Tue Nov 22, 2005 10:26 am ] | ||||||
Post subject: | |||||||
well you need to put/get information.. help files are awesome documentation wrote: To allow two machines to communicate, there must be a server (which calls Net,WaitForConnection) and a client (which calls Net.OpenConnection). The server waits until a client connects and then starts communication between the two. When a connection is established, a net stream is returned that can be used in the same fashion as a file stream (i.e. using puts and gets). Once the connection is finished, the programs call Net.CloseConnection. so after
netStream is your identifier of the client
will send contents of data to the connected client. similarly, you use
to read contents of netStream you could use Net.BytesAvailable(), Net.CharAvailable(), or even Net.LineAvailable() to see if there's anything to be read and processed. you could think of netStream as a file |
Author: | paulkwatyra [ Tue Nov 22, 2005 10:40 am ] |
Post subject: | |
so in my ball game when i have the if statements for when the balls move i have to send the information or get it??? player1: [code] if chars (KEY_UP_ARROW) then y := y + 10 end if if chars (KEY_RIGHT_ARROW) then x := x + 10 end if if chars (KEY_LEFT_ARROW) then x := x - 10 end if if chars (KEY_DOWN_ARROW) then y := y - 10 end if Draw.FillOval (x, y, 4, 4, 13) [/code] so i think you put this: ex. if chars(KEY_DOWN_ARROW) then y:= y-10 (so here i put send this info to other computeror get info from computer)??? end if |
Author: | Tony [ Tue Nov 22, 2005 11:50 am ] | ||||
Post subject: | |||||
no, that way you'll send infomation only when you move down ![]() see your
At this point you know exactly where your ball is, let others know of it. Then read where your opponent's ball is. After exchanging the information, you still know where you're are, and where the other player is supposed to be. Draw both.
|
Author: | paulkwatyra [ Tue Nov 22, 2005 6:19 pm ] |
Post subject: | |
kk thanx |
Author: | Mr. T [ Tue Nov 22, 2005 7:49 pm ] |
Post subject: | Alex's Opinion |
Cervantes wrote: It's hard to know what direction to point him in when he reveals his current programming ability in riddles and contradictions.
SnoopDuck wrote: Maybe to you but..... you can just say hey look up "this" and "this" and that should help you out..... He told you exacly what he needed all you gotta tell him is what he needs,
He's quite the hypocrite in my eyes too. ![]() |
Author: | paulkwatyra [ Wed Nov 23, 2005 9:55 am ] |
Post subject: | |
hey man k i have it kind of working the problem is somethings wrong, it redraws it on the other screen however it disapears here chk it out: [code] const chatPort : int := 5055 var choice : int var netStream : int var netAddress : string var chars, chars2 : array char of boolean var x, y, x2, y2 : int x := 250 y := 200 x2 := 400 y2 := 400 loop put "Enter 1 to run chat server" put "Enter 2 to run chat session" put "Choice: " .. get choice exit when choice = 1 or choice = 2 end loop if choice = 1 then View.Update put "This machine is '", Net.LocalName, "' at net addresss ", Net.LocalAddress put "Waiting for a connection... " netStream := Net.WaitForConnection (chatPort, netAddress) View.Update else put "Enter the address to connect to: " .. get netAddress netStream := Net.OpenConnection (netAddress, chatPort) if netStream <= 0 then put "Unable to connect to ", netAddress return end if end if loop Input.KeyDown (chars) if chars (KEY_UP_ARROW) then y := y + 10 put : netStream, x put : netStream, y get : netStream, x2 get : netStream, y2 end if if chars (KEY_RIGHT_ARROW) then x := x + 10 put : netStream, x put : netStream, y get : netStream, x2 get : netStream, y2 end if if chars (KEY_LEFT_ARROW) then x := x - 10 put : netStream, x put : netStream, y get : netStream, x2 get : netStream, y2 end if if chars (KEY_DOWN_ARROW) then y := y - 10 put : netStream, x put : netStream, y get : netStream, x2 get : netStream, y2 end if Draw.FillOval (x, y, 4, 4, 13) Input.KeyDown (chars2) if chars2 ('w') then y2 := y2 + 10 put : netStream, x2 put : netStream, y2 get : netStream, x get : netStream, y end if if chars2 ('d') then x2 := x2 + 10 put : netStream, x2 put : netStream, y2 get : netStream, x get : netStream, y end if if chars2 ('a') then x2 := x2 - 10 put : netStream, x2 put : netStream, y2 get : netStream, x get : netStream, y end if if chars2 ('s') then y2 := y2 - 10 put : netStream, x2 put : netStream, y2 get : netStream, x get : netStream, y end if Draw.FillOval (x2, y2, 4, 4, 60) delay (20) cls end loop [/code] send me what you think |
Author: | paulkwatyra [ Wed Nov 23, 2005 5:10 pm ] |
Post subject: | |
neone goin to help tony??? |
Author: | paulkwatyra [ Wed Nov 23, 2005 5:10 pm ] |
Post subject: | |
sry help me** |
Author: | Mr. T [ Thu Nov 24, 2005 1:35 am ] |
Post subject: | Alex's Opinion |
No need to flood the topic with more posts. Just click edit and add to your old post. |
Author: | [Gandalf] [ Thu Nov 24, 2005 2:28 am ] |
Post subject: | Re: Alex's Opinion |
Pwned wrote: No need to flood the topic with more posts. Just click edit and add to your old post.
In case you haven't noticed, the edit button has been disabled on posts in any "help" forum ![]() Still, a new post for a small fix like that is not neccessary, someone will help you when they have free time. |
Author: | paulkwatyra [ Thu Nov 24, 2005 8:12 am ] |
Post subject: | |
well how bout u help me ???? |
Author: | ZeroPaladn [ Thu Nov 24, 2005 9:49 am ] |
Post subject: | |
may i suggest looking it up, or finding examples of what your looking for instead of flooding the forums ![]() |
Author: | paulkwatyra [ Thu Nov 24, 2005 9:58 am ] |
Post subject: | |
well arent the forums here to help??? |