Skocz do zawartości

Imge Angle Nie działa !!!


Rekomendowane odpowiedzi

Siema mam poważny problem z grą wyścigową multiplayer:

-gdy widzę auto kolegi to jego sprit nie wykonuje żadnego obrotu przy skręcaniu :/

Jak to naprawić ???

Tak wyglądają eventy w obiekcie auto_inne:

CREATE:

 image_single = 0

STEP:

 image_angle = direction

DRAW:

 //duh
draw_set_blend_mode(bm_add)
draw_sprite_ext(spr_neon,image_index,x,y,1,1,direction,c_white,1)
draw_set_blend_mode(bm_normal)
draw_sprite_ext(sprite_index,image_index,x,y,1,1,direction,c_white,1)

Odnośnik do komentarza
Udostępnij na innych stronach

Pokaż kod odpowiedzialny za multiplayer... a ie dajesz nam kawałki kodu, które na nic się nie przydadza.

 

Swoją drogą: odpuść sobie narazie multiplayer ;)

A to niby czemu mam se odpuszczać multiplayer masz mnie za głupka???

A za multiplayer odpowiada 39dll.dll :P

Odnośnik do komentarza
Udostępnij na innych stronach

Gdzie mam tego szukać ??? w pliku server czy w pliku gra ???
Pytałeś - tak, mam cięza głupka. Wybacz, ale po prostu taki poziom sobą pkazujesz <_<

 

Co za jeleń na prośbę o podanie kodu odpowiadającego za wsyłanie danych mówi, że kozysta z 39DLL?

 

A jak ci wyjaśnili, o co chodzi to się pytasz, gdzie tego szukać '-.-

 

Wiesz, może przeczytaj ten przykład którego nawet nie przeczytałeś.

 

PS: Wybacz krytykę. Ale przyznaj się - oparłeś grę na przykładzie chodzenia ludzikaami i nawet nie zajrzałęs do kodu...

 

Edit: Swoją drogą jeśli to dwuosobowe wyścigi to nie musisz korzystać z serwera... Ale wątpię, że max dwuosobowe :P

Edit2: Yoda szybszy :D Ale ja więcej napisaęłm xD Choć w sumie - nie warto...

Odnośnik do komentarza
Udostępnij na innych stronach

Więc tak z servera :

Step obiektu klient :

/* ==================== */
/*	   -START-		*/
/* ==================== */
/*  Receiving Messages  */
/* ==================== */

//Create the variables to be used
var messagesize, messageid;

//Check for messages
while(1)
{
//Try to receive a message using UDP
messagesize = receivemessage(obj_server.serverudp);
//If no UDP message was received then we try TCP
if (messagesize <=0) messagesize = receivemessage(tcp);
//If no messages were received, break
if (messagesize <=0) break;
//If a message was received, get the message ID...
messageid = readbyte();
//...and then use it to check what message it was
switch(messageid)
{   
case 2:
//Update position
var player, value;
value = readbyte();
//script_addline(string(global.players[value]),c_black);
player = global.players[value];
player.x = readshort();
player.y = readshort();
player.sprite_index = readshort();
player.image_speed = readshort();
player.image_index = readshort();
clearbuffer();
writebyte(5);
writebyte(value);
writeshort(player.x);
writeshort(player.y);
writeshort(player.sprite_index);
writeshort(player.image_speed);
writeshort(player.image_index);
with(obj_client)
{
sendmessage(tcp);
}
break;

case 3:
//Player left
var playerid, username;
playerid = readbyte();
username = readstring();
clearbuffer();
writebyte(6);
writebyte(playerid);
writestring(username,true);
with(obj_client)
{
sendmessage(tcp);
}
script_addline(username + " has left.",c_black);
with(global.players[playerid])
{
instance_destroy();
}
global.players[playerid] = -1;
break;

case 4:
//Chat message
chatmessage = readstring();
script_addline(chatmessage,c_black);
clearbuffer();
writebyte(8)
writestring(chatmessage,true);
with(obj_client)
{
	sendmessage(tcp);
}
break;
}
}

Gra :

Obiekt Klient:

CREATE:

/* ==================== */
/*	   -START-		*/
/* ==================== */
/*	Connecting to	 */
/*	 the server.	  */
/* ==================== */

end_game = false

//Start everything
dllinit(0,true,false);

//initiate the lines
script_initlines();

//get username
global.username = get_string("Username:","");

//get ip of server to join
global.serverip = get_string("Server IP:","127.0.0.1");

//port.
global.serverport = 12564;

//Connect to the server using TCP
global.clienttcp = tcpconnect(global.serverip,global.serverport,1);

//Check to see if it connected...
if (!tcpconnected(global.clienttcp))//if connected is false
{
//...if not, close the socket, tell the player and end the game
show_message("Unable to connect to the server.");
end_game = true
}
else
{
//If it did connect we tell the player
setnagle(global.clienttcp,1);
script_addline("Connected to the server using TCP.",c_black);

//After that we send our username to the server...
clearbuffer();
writestring(global.username,true);
sendmessage(global.clienttcp);
}

//...set up the player list...
var i;
for(i=0;i<20;i+=1)
{
players[i] = -1;
}

//...and then we have to welcome to the player to the game :P
script_addline(global.username+", welcome to marbs online engine, made with a lot of help from -ONL1N3-.",c_black);

//Setup the ping
deltatime = current_time;

//set the ping
ping = 0;

//after this time the player will dissconnect
timeout = 8000;

//chat
blink = true

//whether to draw the "|"
send = false

//used for the "|"
alarm[0] = 5

/* ==================== */
/*		-END-		 */
/* ==================== */
/*	Connecting to	 */
/*	 the server.	  */
/* ==================== */

Aralm0:

//reverses the blink
blink = !blink
alarm[0] = 30

Step:

/* ==================== */
/*	   -START-		*/
/* ==================== */
/*  Receiving Messages  */
/* ==================== */

//Create the variables to be used
var messagesize, messageid;

//Check for messages
while(1)
{
//Receive the message using TCP
messagesize = receivemessage(global.clienttcp);

//If no message was received, break
if (messagesize <= 0) break;

//If a message was received, get the message ID...
messageid = readbyte();

//Set the ping to 0 because we got a message
ping = 0;

//...and then use it to check what message it was
switch(messageid)
	{
	//If the message ID is 1
	case 1:
	//Store the message as our player ID
	global.myid = readbyte();
	if end_game = true
		{
		clearbuffer();
		writebyte(4);
		writestring(global.username+" can not join.",true);
		sendmessage(global.clienttcp);

		scr_online_gameend();
		exit;
		}
	else
		{
		obj_player_self.alarm[0] = 1;
		}
	//And then break from the loop. If you forget this part then you might get errors.
	break;

	case 2:
	//Server is full message
	show_message("Sorry! The server is full.");
		if end_game = true
		{
		scr_online_gameend();
		exit;
		}
	break;

	case 3:
	//New Player (create)
	var userid, name, user;
	userid = readbyte();
	user = instance_create(obj_player_self.xstart,obj_player_self.ystart,obj_player_other);
	user.pid = userid;
	name = readstring();
	user.username = name;
	players[userid] = user;
	script_addline(name + " has joined.",c_black);
	break;

	case 4:
	//New Player (chat message)
	var name, userid;
	userid = readbyte();
	name = readstring();
	user = players[userid];
	user.username = name;
	script_addline(name + " has joined.",c_black);
	break;

	case 5:
	//Update other players' positions
	value = readbyte();
	player = players[value];
	player.x = readshort();
	player.y = readshort();
	player.sprite_index = readshort();
	player.image_speed = readshort();
	player.image_index = readshort();
	player.direction = readshort();
	break;

	case 6:
	//Player left
	var playerid, username;
	playerid = readbyte();
	username = readstring();
	script_addline(username + " has left.",c_black);
	with(players[playerid])
		{
		instance_destroy();
		}
	players[playerid] = -1;
	break;

	case 7:
	//The server has shut down
	show_message("The server has shut down.");
	game_end();
	break;

	case 8:
	//Chat message
	script_addline(readstring(),c_black);
	break;

	case 9:
	//Server message
	script_addline("Server: " + readstring(),c_red);
	break;
	}
}

Game End:

scr_online_gameend()

DRAW:

//Set the color
draw_set_color(c_black);

//Draw the chat
script_drawlines(view_xview[0]+16,view_yview[0]+16);

//Draw the text for the chat bar
if send = true
{
draw_set_alpha(0.5)
draw_set_color(c_black)
draw_roundrect(view_xview[0]+16-2,view_yview[0]+144-2,view_xview[0]+16+string_width(keyboard_string)+5,view_yview[0]+144+15,0)
draw_set_alpha(1)
draw_set_color(c_white)
if blink = true && keyboard_string != ""
draw_text(view_xview[0]+16,view_yview[0]+144,keyboard_string+"|");
else
draw_text(view_xview[0]+16,view_yview[0]+144,keyboard_string);
draw_set_color(c_black)
}
//Draw the ping
draw_text(view_xview[0]+544,view_yview[0]+16,"Ping: " + string(ping) + "ms");

//Draw FPS
draw_text(view_xview[0]+466,view_yview[0]+16,"FPS: " + string(fps));

//Draw the username above the player (self)
draw_set_halign(fa_center);
draw_text(obj_player_self.x-15,obj_player_self.y-25,global.username);

//Draw the username above the player (other)
with(obj_player_other)
{
draw_text(self.x-15,self.y-25,username);
}

Press Enter:

if send = true
{
//Make sure that the player typed something before sending the message...
if keyboard_string != ""
	{
	//Send chat message
	clearbuffer();
	writebyte(4);
	writestring(global.username + ": " + keyboard_string,c_red);
	sendmessage(global.clienttcp);
	keyboard_string = "";
	}
send = false
exit;
}
else
{
keyboard_string = ""
send = true
exit;
}

 

Hint: do dłuższych kawałków kodu używajcie znacznika codebox.

Maximal

Odnośnik do komentarza
Udostępnij na innych stronach

Kurdę! Popatrz w Alarm[0] bohatera i podaj nam kod <_< a nie jakieś głupoty piszesz...

Już widzę co tam masz źle.... Wymaż kod w stepie obj_control i daj to:

GML
/* ==================== */

/* -START- */

/* ==================== */

/* Receiving Messages */

/* ==================== */

 

//Create the variables to be used

var messagesize, messageid;

 

//Check for messages

while(1)

{

//Receive the message using TCP

messagesize = receivemessage(global.clienttcp);

 

//If no message was received, break

if (messagesize <= 0) break;

 

//If a message was received, get the message ID...

messageid = readbyte();

 

//Set the ping to 0 because we got a message

ping = 0;

 

//...and then use it to check what message it was

switch(messageid)

{

//If the message ID is 1

case 1:

//Store the message as our player ID

global.myid = readbyte();

if end_game = true

{

clearbuffer();

writebyte(4);

writestring(global.username+" can not join.",true);

sendmessage(global.clienttcp);

 

scr_online_gameend();

exit;

}

else

{

obj_player_self.alarm[0] = 1;

}

//And then break from the loop. If you forget this part then you might get errors.

break;

 

case 2:

//Server is full message

show_message("Sorry! The server is full.");

if end_game = true

{

scr_online_gameend();

exit;

}

break;

 

case 3:

//New Player (create)

var userid, name, user;

userid = readbyte();

user = instance_create(obj_player_self.xstart,obj_player_self.ystart,obj_player_other);

user.pid = userid;

name = readstring();

user.username = name;

players[userid] = user;

script_addline(name + " has joined.",c_black);

break;

 

case 4:

//New Player (chat message)

var name, userid;

userid = readbyte();

name = readstring();

user = players[userid];

user.username = name;

script_addline(name + " has joined.",c_black);

break;

 

case 5:

//Update other players' positions

value = readbyte();

player = players[value];

player.x = readshort();

player.y = readshort();

player.sprite_index = readshort();

player.image_speed = readshort();

player.image_index = readshort();

player.image_angle = readshort(); //Tu masz blad...

break;

 

case 6:

//Player left

var playerid, username;

playerid = readbyte();

username = readstring();

script_addline(username + " has left.",c_black);

with(players[playerid])

{

instance_destroy();

}

players[playerid] = -1;

break;

 

case 7:

//The server has shut down

show_message("The server has shut down.");

game_end();

break;

 

case 8:

//Chat message

script_addline(readstring(),c_black);

break;

 

case 9:

//Server message

script_addline("Server: " + readstring(),c_red);

break;

}

}

Odnośnik do komentarza
Udostępnij na innych stronach

A prącie bardzo masz alarm0 bohatera

//Update position. alarm is called in obj_client
clearbuffer();
writebyte(2);
writebyte(global.myid);
writeshort(x);
writeshort(y);
writeshort(sprite_index);
writeshort(image_speed);
writeshort(image_index);
writeshort(direction);
sendmessage(global.clienttcp);

//Redo it
alarm[0] = 1;

Odnośnik do komentarza
Udostępnij na innych stronach

Nie robiłem jeszcze gier multi, ale sądzę, że to co podał kolega wyżej jest dobre, ale trzeba jeszcze gdzieś to odebrać. Chyba:

GML
image_angle = readshort();

Jeśli jesteś niegłupi, to wiesz gdzie to trzeba wstawić i wiesz co trzeba wpisać przed image_angle.

Odnośnik do komentarza
Udostępnij na innych stronach

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...