Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, AndrewAMD, TedMar), 1,371 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
DX_Ball 2 #342063
09/23/10 05:28
09/23/10 05:28
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
hey all.
at the last days i had reaching an code to animate the ball but now i have an thinking error the compiler out from checking the (if statement when it's apply the first statement i want it to continue checking i want to animate the ball to be in an three closed walls to impact with it and at the fourth wall the blade make it's objective to keep the ball between the three walls and the blade ..
here is the code

action bar()
{
while(1)
{
if (key_a)
{
c_move (my, vector(0, 0, -10 * time_step), nullvector, GLIDE);
}
if (key_d)
{
c_move (my, vector(0, 0, 10 * time_step), nullvector, GLIDE);
}
wait (1);
}
}

action ball()
{
var ball_speed =30;
var top_border= 100;
var Rside_border= 400;
var Lside_border= -200;
while(1)
{
c_move (my, vector(0, 0, ball_speed * time_step), nullvector, GLIDE);
c_move (my, vector(0, -ball_speed * time_step, 0), nullvector, GLIDE);


if (my.z>=top_border)
{
my.z-=3 -random(3);
my.y+=3 +random(3);

if(my.y<=Lside_border)
{
my.y-=ball_speed*time_step - random(3);
my.z+=ball_speed*time_step + random(3);
}
if (my.y>=Rside_border)
{
my.y+=ball_speed*time_step -random(3);
my.z+=ball_speed*time_step + random(3);
}
}
wait(1);
}
}

hint the actions is assigned to the models the bar and the ball. and the game is 2d game the ball and bar are models . the level consisting in an sprite as background.


Last edited by EID; 09/23/10 06:19.
Re: DX_Ball 2 [Re: EID] #342079
09/23/10 10:27
09/23/10 10:27
Joined: Jul 2009
Posts: 1,198
Berlin, Germany
L
Liamissimo Offline
Serious User
Liamissimo  Offline
Serious User
L

Joined: Jul 2009
Posts: 1,198
Berlin, Germany
Hehe, I am sorry but could you describe again what you want? I don't get it laugh


"Ich weiss nicht genau, was Sie vorhaben, aber Sie können keine Triggerzonen durch Ihr Level kullern lassen."
-JCL, 2011
Re: DX_Ball 2 [Re: Liamissimo] #342122
09/23/10 17:47
09/23/10 17:47
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
never mind my friend u can see what i want from this link at youtube (http://www.youtube.com/watch?v=YvkEtVpkGTs) .i want to make a game like this...
Thanks a lot again laugh

Last edited by EID; 09/23/10 17:48.
Re: DX_Ball 2 [Re: EID] #342125
09/23/10 18:17
09/23/10 18:17
Joined: Nov 2009
Posts: 89
Germany, NRW
T
TrackingKeks Offline
Junior Member
TrackingKeks  Offline
Junior Member
T

Joined: Nov 2009
Posts: 89
Germany, NRW
And what is the problem? laugh


Gamestudio: A7.82 Commercial/A8 Commercial
System specs (Laptop):
Windows 7 64bit
DirectX v10.1
Intel Core i7-720QM CPU @ 1,60 GHz
4GB DDR2 Ram
NVIDIA GeForce GT 230M (1024MB)
Re: DX_Ball 2 [Re: TrackingKeks] #342126
09/23/10 18:20
09/23/10 18:20
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
the problem that the compiler when he apply the first if statement it's out of it's loop i want to continue in the loop to be like this (http://www.youtube.com/watch?v=YvkEtVpkGTs)

Re: DX_Ball 2 [Re: EID] #342147
09/24/10 07:07
09/24/10 07:07
Joined: Sep 2007
Posts: 62
Germany
B
bodden Offline
Junior Member
bodden  Offline
Junior Member
B

Joined: Sep 2007
Posts: 62
Germany
I think, with this code, it can't work. You never change ball_speed, so the ball can never bounce from the wall.

You don't need two c_move's, because you can put both directions (x/y) in one c_move-vector.

If you use the same value for x/y, the ball will allways fly in a 45° angle. You could use differnet vars for x and y speed. Also, you could use collision-detection and the BOUNCE-result of a collision to set the new direction of the ball. In your code, you don't change any speed, when collision with the wall.

Your brackets are not correct. In the ball-action the checks for the left and right wall are only done, when the ball hits the upper wall. I've formated your code to make it clear
Code:
action ball()
{
	var ball_speed =30;
	var top_border= 100;
	var Rside_border= 400;
	var Lside_border= -200;
	while(1)
	{
		c_move (my, vector(0, 0, ball_speed * time_step), nullvector, GLIDE);
		c_move (my, vector(0, -ball_speed * time_step, 0), nullvector, GLIDE);
		
		
		if (my.z>=top_border)
		{
			my.z-=3 -random(3); 
			my.y+=3 +random(3); 
		
			if(my.y<=Lside_border)
			{
				my.y-=ball_speed*time_step - random(3);
				my.z+=ball_speed*time_step + random(3);
			}
			if (my.y>=Rside_border)
			{
				my.y+=ball_speed*time_step -random(3);
				my.z+=ball_speed*time_step + random(3);
			}
		}
		wait(1);
	}
}



Last edited by bodden; 09/24/10 07:10.
Re: DX_Ball 2 [Re: bodden] #342148
09/24/10 07:59
09/24/10 07:59
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
really thank you bodden i will do it now but we have another problem that the compiler exit from it's while(1) loop after applying the first If statement . i wana to be continue in the loop.

Thanks bodden.

Re: DX_Ball 2 [Re: EID] #342157
09/24/10 08:50
09/24/10 08:50
Joined: Sep 2007
Posts: 62
Germany
B
bodden Offline
Junior Member
bodden  Offline
Junior Member
B

Joined: Sep 2007
Posts: 62
Germany
I can't see any reason in this code, why the while(1)-loop should be left. Do you use more than 1 ball? Could you post your main-function?

Re: DX_Ball 2 [Re: bodden] #342160
09/24/10 08:55
09/24/10 08:55
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
sure the while (1) loop is for the if statement . i will post the main- function

here it

function main()
{
level_load("TrySprite.wmb"); // load the level
wait (2);
while (1)
{
camera.x = 200;
camera.y = 0;
camera.z =-50;
wait (1);
}
}

Re: DX_Ball 2 [Re: EID] #342161
09/24/10 08:56
09/24/10 08:56
Joined: Jul 2010
Posts: 32
E
EID Offline OP
Newbie
EID  Offline OP
Newbie
E

Joined: Jul 2010
Posts: 32
in the option of the game u could use more than 1 ball

Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1