Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, degenerate_762, AndrewAMD, ozgur), 774 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Print Thread
Rate Thread
Page 1 of 2 1 2
[Code/ Idea] bullets without entities #391795
01/15/12 23:49
01/15/12 23:49
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
When you're creating a shooter (side-scroller, FPS, space shooter), you'd probably most of the time use models for flying bullets. As the (ent_)creation of all those bullets, their removal, rendering and esp. c_move (that includes a USE_BOX trace) gets quite slow, I suggest you don't use models at all and simply run a function that emulates a bullet as follows:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

void p_bullet(PARTICLE* p)
{
	vec_set(p.blue,vector(random(128),128+random(128),255));
	set(p, STREAK | BRIGHT);
	p.alpha = 100;
	p.size = 10;
	p.lifespan = 0.01;
	p.event = NULL;
}

void bullet_create(VECTOR* vpos,VECTOR* vang,var speed)
{
	var alive = 16;
	VECTOR pos,temp,vel;
	
	vec_set(pos,vpos);
	vec_set(vel,vector(speed,0,0));
	vec_rotate(vel,vang);

	while(alive > 0)
	{
		// calculate new position
		vec_set(temp,vel);
		vec_scale(temp,time_step);
		vec_add(temp,pos);
		c_trace(pos,temp,IGNORE_PASSABLE | USE_POLYGON); // optional: SCAN_TEXTURE
		if(trace_hit)
		{
			/*if(you) ... // reduce health, blood effect
			else ... // spark effect*/
			alive = 0;
		}
		effect(p_bullet,1,pos,vel); // you may want to shorten vel on impact
		vec_set(pos,temp); // move to new position

		alive -= time_step;
		wait(1);
	}
}


void main()
{
	fps_max = 60;
	video_mode = 9;
	level_load(NULL);
	ent_create(CUBE_MDL,vector(500,-10,-5),NULL);
	def_move();
	while(1)
	{
		if(mouse_left)
		{
			VECTOR temp;
			vec_set(temp,vector(5,-20,-10));
			vec_rotate(temp,camera.pan);
			vec_add(temp,camera.x);
			bullet_create(temp,camera.pan,500);
			wait(-0.1);
		}
		wait(1);
	}
}



You can still use c_ignore and most of the events. Additionally, if you really need a lot of bullets, you could handle all of them with just one wait (save the bullets in some array/ linked list).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: [Code/ Idea] bullets without entities [Re: Superku] #391814
01/16/12 09:36
01/16/12 09:36
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Why should i use entities? I use c_trace =/


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [Code/ Idea] bullets without entities [Re: alibaba] #391817
01/16/12 09:55
01/16/12 09:55
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
Quote:
Why should i use entities? I use c_trace =/


I wonder how you make a blue c_trace ?

a c_trace is for gaining information
and ent_create is for making something "3d" to get rendered.


Re: [Code/ Idea] bullets without entities [Re: Damocles_] #391819
01/16/12 10:16
01/16/12 10:16
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Ah, you mean to see the bullet flying? For that i use particles


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [Code/ Idea] bullets without entities [Re: alibaba] #391870
01/16/12 17:28
01/16/12 17:28
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Of course you normally use c_trace for FPS, but have a look at the following video (or any space shooter) and tell me how you'd do that with a regular c_trace and particles:
http://www.youtube.com/watch?v=vmWDRlbS6aQ&t=10s


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: [Code/ Idea] bullets without entities [Re: Superku] #391894
01/16/12 19:53
01/16/12 19:53
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Ahhhh! Understood laugh thanks!


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [Code/ Idea] bullets without entities [Re: alibaba] #391938
01/17/12 13:44
01/17/12 13:44
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
i could xD
anyway, question, why do you think this is more efficient than using c_move ?
because we're still tracing per frame per bullet correct? even though its short traces, you think it'll be faster than the c_move approach?

Re: [Code/ Idea] bullets without entities [Re: darkinferno] #391945
01/17/12 15:10
01/17/12 15:10
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
yes it will be
because we have only a single trace colliding with geometry, not geometry colliding with geometry. also a model has to be clipped, drawn, depth-sorted and so on
so i think it will be much faster then c_move


Visit my site: www.masterq32.de
Re: [Code/ Idea] bullets without entities [Re: MasterQ32] #391953
01/17/12 16:42
01/17/12 16:42
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
MasterQ32 is right, esp. because c_move uses USE_BOX and the entity creation and deletion takes a lot of time, too.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: [Code/ Idea] bullets without entities [Re: Superku] #393619
02/05/12 16:17
02/05/12 16:17
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Is there anyway to make this work with isometric camera? Streak and beam does't work.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

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