Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (RealSerious3D, rvl, tomaslolo), 685 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
creating something out of nothing. #76694
06/04/06 21:29
06/04/06 21:29
Joined: May 2005
Posts: 222
T
tek Offline OP
Member
tek  Offline OP
Member
T

Joined: May 2005
Posts: 222
So far all the help that I have received here has worked in my game and I really appreciate, I would like to ask another question, I am building a pyramid level, this level is filled with traps, like fire and falling walls, I would like to build a box that shoots spears and keeps repeating by creating another spear after a couple of seconds, also I would like that the spears that the box creates disappear after a couple of seconds how would make a code for this ?

Re: creating something out of nothing. [Re: tek] #76695
06/04/06 21:42
06/04/06 21:42
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
ulillillia Offline
Senior Expert
ulillillia  Offline
Senior Expert

Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
Look up ent_create and ent_remove in the manual. As far as the design of your level goes, what I normally do is just take out GIMP and start formulating a plan from a top-down type of view.


"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip My 2D game - release on Jun 13th; My tutorials
Re: creating something out of nothing. [Re: tek] #76696
06/04/06 23:09
06/04/06 23:09
Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
anonymous_alcoho Offline
Senior Developer
anonymous_alcoho  Offline
Senior Developer

Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
Here's some untested pseudo code

Code:


function hitEvent()
{
if(event_type == event_entity)
{
if(you == player)
{
player.health -= 50; //reduce player health
}
ent_remove(me);
}
if(event_type == event_block)
{
ent_remove(me);
}
return;
}

action arrowFly
{
var arrowCounter
my.enable_block = on;
my.enable_entity = on;
my.event = hitEvent;
my.passable = on;
while(arrowCounter < 100) //play with this (arrow's flight time)
{
my.skill20 = 10; //play with this (arrow's speed)
my.skill21 = 0;
my.skill22 = 0;
move_mode = ignore_passable;
ent_move(my.skill20,nullvector); //or use c_move
if(vec_dist(my.x,you.x) < 50)
{
my.passable = off;
}
wait(1);
}
ent_remove(me);
}
action arrowBox
{
var counter;
while(1) //play with this number (amt of time between firing an arrow
{
if(counter == 50)
{
you = ent_create(arrowMDL,my.x,arrowFly);
}
counter += 1;
if(counter < 50)
{
counter = 0;
}
wait();
}




arrowBox creates an arrow everytime the counter gets to fifty. When the counter is greater than fifty, the counter resets. The arrow flies straight out along x-axis until its counter reaches 100 ticks, its flight time. At 100, the while loop is broken so the arrow removes itself. If the arrow hits an object named player, health is reduced and the arrow is removed. If the arrow hits a block, it is removed.


"Oh no, it's true! I'm a love magnet!" Calvin from Calvin and Hobbes My name's Anonymous_Alcoholic.
Re: creating something out of nothing. [Re: anonymous_alcoho] #76697
06/04/06 23:31
06/04/06 23:31
Joined: Dec 2005
Posts: 23
USA
Prog_plus_plus Offline
Newbie
Prog_plus_plus  Offline
Newbie

Joined: Dec 2005
Posts: 23
USA
I know you said it was pseudocode, but to shed some more light on it, I altered some things.

Problems. Revised Code:
Code:

function hitEvent()
{
if(event_type == event_entity)
{
if(you == player)
{
player.health -= 50; //reduce player health
}
ent_remove(me);
}
if(event_type == event_block)
{
ent_remove(me);
}
return;
}

action arrowFly
{
var arrowCounter=0;
my.enable_block = on;
my.enable_entity = on;
my.event = hitEvent;
my.passable = on;
while(arrowCounter < 100) //play with this (arrow's flight time)
{
my.skill20 = 10; //play with this (arrow's speed)
my.skill21 = 0;
my.skill22 = 0;
move_mode = ignore_passable;
ent_move(my.skill20,nullvector); //or use c_move
if(vec_dist(my.x,you.x) < 50)
{
my.passable = off;
}
wait(1);
arrowCounter += 1; //arrowCounter must increment to prevent dead loop
}
ent_remove(me);
}

action arrowBox
{
var counter=0; // counter has initial value of zero
while(1) // continue firing indefinitly
{
if(counter == 50) //play with this number(amt of time b/t firing an arrow
{
you = ent_create(arrowMDL,my.x,arrowFly); //create new arrow
}
counter += 1;
if(counter >= 50) // if counter is GREATER than 50 (or equal), reset
{
counter = 0;
}
wait(1);
}
}




Making the world better, one mouse click at a time. -- DETAILS -- version:.... commercial 6.31.4/WED V6.269 OS:......... Windows XP pro processor:. 2.8 GHz P4 RAM:....... 1 GB
Re: creating something out of nothing. [Re: Prog_plus_plus] #76698
06/05/06 00:36
06/05/06 00:36
Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
anonymous_alcoho Offline
Senior Developer
anonymous_alcoho  Offline
Senior Developer

Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
oops! my bad. i hate those <> signs. can never til which until i test . . .


"Oh no, it's true! I'm a love magnet!" Calvin from Calvin and Hobbes My name's Anonymous_Alcoholic.
Re: creating something out of nothing. [Re: anonymous_alcoho] #76699
06/05/06 07:20
06/05/06 07:20
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I know this is of no importance at all, but you could get rid of one of these if statements as far as I know:
Code:

action arrowBox
{
var counter=0; // counter has initial value of zero
while(1) // continue firing indefinitly
{
if(counter == 50) //play with this number(amt of time b/t firing an arrow
{
you = ent_create(arrowMDL,my.x,arrowFly); //create new arrow
}
counter += 1;
counter %= 50;
wait(1);
}
}



Re: creating something out of nothing. [Re: Xarthor] #76700
06/06/06 19:39
06/06/06 19:39
Joined: Dec 2005
Posts: 23
USA
Prog_plus_plus Offline
Newbie
Prog_plus_plus  Offline
Newbie

Joined: Dec 2005
Posts: 23
USA
I didn't even think about the mod operator. Although you would have to use counter%51. counter%50 would change the value of counter to zero once is hits 50 so the if statement would never evaluate to true.
For those of you who have no clue what the % ("mod") symbol is, I will explain. This may not be the best or clearest explanation but I will try. If anyone wants to reply with clarification, please feel free too.
Now then:
The modulus operator %(percent sign).
Mod will actually subtract the multiples of a number from another number. For example, if you were to do 150 % 50, you would get a result of zero. Reason is because 150 has 3 multiples of 50 in it. So 150-(3*50) = 0. If it were 153%50 instead, the answer would be 3 since 153-(3*50)=3. For extra clarification, let's do one more. 23 % 7. Well if you continue to take multiples of 7 without going over 23, you find that the closest you can get is 21 (i.e. 3 multiples of 7). So 23 - (3*7) = 2.
Now what this number actually represents is the integer remainder of division. So 23/7 would be 3 2/7. So the remainder 2/7 is taken and the numerator is your Mod result.
In the case with the arrows(in the code above), what this does is keep the value of the variable counter to a number in the range of 0 to 50. Once it reaches a value of 50, the if statement is true, code is executed in the corresponding statement block and counter gets reset to 0.
All this should probably go in the coding section but I figured since it was brought up, I would shed some light on it for those who didn't know. I try to be as helpful as I can since I know I have received a lot of help from other people on here.


Making the world better, one mouse click at a time. -- DETAILS -- version:.... commercial 6.31.4/WED V6.269 OS:......... Windows XP pro processor:. 2.8 GHz P4 RAM:....... 1 GB
Re: creating something out of nothing. [Re: Prog_plus_plus] #76701
06/06/06 19:52
06/06/06 19:52
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
@Prog_Plus_plus:
Yeah you're right about the 50, however changing the order of the instructions does help too
Oh and good explanation about the % Operator.

@topic:
here is an update, tested version:
Code:

action arrowBox
{
var counter=0; // counter has initial value of zero
while(1) // continue firing indefinitly
{
counter += 1;
if(counter == 50) //play with this number(amt of time b/t firing an arrow
{
you = ent_create(arrowMDL,my.x,arrowFly); //create new arrow
}
counter %= 50;
wait(1);
}
}



Re: creating something out of nothing. [Re: Prog_plus_plus] #76702
06/06/06 21:05
06/06/06 21:05
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
ulillillia Offline
Senior Expert
ulillillia  Offline
Senior Expert

Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
Another way to explain the modulus operator is like this, in a not-so-decent coding method:

Code:

function get_remainder(number, value)
{
temp = int(number/value);
return(number-value*time);
}

function another_function(parameters)
{
some_var = 160;
// ... more code above here
some_var = get_remainder(some_var, 30); // returns 10 and the same as
// some_var %= 30; // also returns 10
// ... more code below here
}



Although code like this is meaningless, this is the basic algorithm behind it - it's not all that complex either.


"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip My 2D game - release on Jun 13th; My tutorials

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