Shooter Demo

by Forum_account
A sample top-down shooter.
ID:120078
 
A basic top-down shooter that uses the Dynamic Lighting, Mouse Position, and Pixel Movement libraries.

Look through the code to see how things work, or expand on it to make your own game. You can make simple modifications - new maps and graphics. Or more complex changes - new enemies and attacks.
Right-click seems to break the tracking.

Also, in the room with three NPC's my CPU shot up to 100% and the game slowed down. This is a bit much for single core processors.
SuperAntx wrote:
Right-click seems to break the tracking.

Also, in the room with three NPC's my CPU shot up to 100% and the game slowed down. This is a bit much for single core processors.

The NPCs don't do anything particularly CPU intensive, so I'm not sure why they'd cause a significant boost in CPU usage.

You can try adding this line to world/New() to see if it helps lower CPU usage:

lighting.pixel_movement = 0
That boosts performance a considerable amount. Now it seems only the mouse tracking is slow with three or more enemies in the same room. Seems like it only updates the position once every second or two.
SuperAntx wrote:
That boosts performance a considerable amount. Now it seems only the mouse tracking is slow with three or more enemies in the same room. Seems like it only updates the position once every second or two.

How high is the CPU usage in that case?

I've noticed problems with the responsiveness of mouse updates but I figure it's some type of BYOND bug - it deals with screen objects and user input, both are things I've noticed BYOND handle poorly. I'm hoping this will be fixed by getting a built-in proc to get mouse coordinates.
The processor I'm using is an AMD Athlon 64 3200+. Here's a breakdown of the CPU usage, baseline is 0-1CPU before running the game, lighting.pixel_movement is set to 0. Screenshot.

30: Idle
65: Aiming
75: Moving
88: Moving & Aiming
75: Idle with enemy Aggro.
95-100: Moving with enemy Aggro.
Do you have hardware rendering on? If its software rendering that'd explain the CPU usage - that's a lot to draw. I'm not sure why enemy activity makes much of a difference. It has to draw projectiles but there aren't that many of them.
I get 12 errors EVERYTIME i try to compile this.
D-Cire wrote:
I get 12 errors EVERYTIME i try to compile this.

Either I can try guessing what they are or you can tell me :-)
Forum_account wrote:
Do you have hardware rendering on?

Yes.

D-Cire wrote:
I get 12 errors EVERYTIME i try to compile this.

You're probably missing one of the required libraries.
Im not, ive already looked over it, delted the required and re-added them etc. Still get the errors.
What are the errors you're getting?
FUUUUUUUUU.
I was just about to release a game with my own shooter physics! ARGH.
But the enemy A.I. is useful.
I get twenty five error when I run this. Too bad.

loading shooter-example.dme
player.dm:115:error: light: undefined var
player.dm:116:error: light.intensity: undefined var
player.dm:118:error: light.intensity: undefined var
lights.dm:40:error: light.off: undefined var
lights.dm:49:error: light: undefined var
lights.dm:50:error: light.dir: undefined var
player.dm:74:error: light: undefined var
player.dm:75:error: light.intensity: undefined var
player.dm:10:error: lighting.init: undefined var
player.dm:11:error: lighting.init: undefined var
player.dm:71:error: client.track_mouse: undefined proc
player.dm:144:error: MouseUpdate: undefined proc
lights.dm:11:error: dir: undefined var
lights.dm:12:error: s.y: undefined type: s.y
lights.dm:12:error: y: undefined var
lights.dm:13:error: dir: undefined var
lights.dm:14:error: s.y: undefined type: s.y
lights.dm:14:error: y: undefined var
lights.dm:15:error: dir: undefined var
lights.dm:16:error: s.x: undefined type: s.x
lights.dm:16:error: x: undefined var
lights.dm:17:error: dir: undefined var
lights.dm:18:error: s.x: undefined type: s.x
lights.dm:18:error: x: undefined var
lights.dm:7:error: lum: undefined proc

shooter-example.dmb - 25 errors, 0 warnings (double-click on an error to jump to it)
Clicking W. ASD do nothing.
runtime error: Cannot read null.x
proc name: apply (/light/proc/apply)
Warning: further proc crash messages are being suppressed to prevent overload...
Tsfreaks wrote:
Clicking W. ASD do nothing.
runtime error: Cannot read null.x
proc name: apply (/light/proc/apply)
Warning: further proc crash messages are being suppressed to prevent overload...

It looks like a problem with the Pixel Movement library. If you switch it back to Native mode it should work. The PM library will be getting a big udpate soon, so I'll just make sure that fixes this problem.
For some reason when using these libraries I am unable to enable the right mouse button properly. When I enable it, right-clicking still registers as a left click. Here is a snippet of code in case it helps.
MouseDown(control,params)
params = params2list(params)
if("right" in params)
world<<"right-clicked"
else if("left in params")
world<<"left-clicked"

I always get the output "left-clicked".
This code works when it is separated from these libraries.
Thanks in advance.
In response to Kiohstuff
Kiohstuff wrote:
For some reason when using these libraries I am unable to enable the right mouse button properly. When I enable it, right-clicking still registers as a left click. Here is a snippet of code in case it helps.
MouseDown(control,params)
params = params2list(params)
if("right" in params)
world<<"right-clicked"
else if("left in params")
world<<"left-clicked"

I always get the output "left-clicked".
This code works when it is separated from these libraries.
Thanks in advance.

Add "world << params" as the first line of the MouseDown() proc to make sure that the params are what you think they should be.

The atom's MouseDown() proc takes three parameters, the client's takes four. So what you're calling "params" there is actually the control parameter. I don't think this has anything to do with what libraries are included.
Page: 1 2