PDA

View Full Version : NovaSxorp - A computer game



ZombieJesus
03-10-2007, 05:40 AM
So, I threw this together to get a feel for the engine.

It's a clone of a game that I originally wrote in C++, but it turned out that that was the extent of my ability as a C++ programmer and I couldn't advance it any more. So here it is in Novashell. It is a simple arcade shooter game.

I intended to make it a little better before posting it, but I've run into some problems and I figured I'd ask about some things before continuing.

1) Upon the player dying I tried to make the game return to the Intro menu and let the player choose a new game or quit. I used the map manager's SetActiveMapByName function to open the level, but this results in an unresponsive screen. I did notice, however, that in that screen if you press escape you stay in Intro, but it becomes responsive again. Am I loading the map wrong? Is it incorrect to use SetActiveMap on Intro? This has me confused.

Also related to this is that at one point I intended to just stay in main on the player's death and start a new game instantly. This didn't work because I couldn't figure out how to reset the map (clear it of entities and such) because if I used UnloadMapByName on Main, Novashell crashed. Again I ask, am I doing that incorrectly or are you not supposed to unload Main maybe? All in all I am pretty confused by the map manager right now.

2) This is actually also similar to the first one. When you are playing the game and press escape to return to Intro it works fine except that it tells me that I tried to call a nil value at some point in one of my scripts. It references a line in which I use RunFunction on an entity in Main. I'm guessing that Main had been unloaded when I set the active map to Intro, but by looking at my code I would think that it shouldn't even call that function after I've set the map to Intro.

Another thing that happens when you press escape is that sometimes Novashell will display the Saving... message momentarily and then just quit. But that seemed to happen randomly so I'm not sure if I fixed that, or if it just decided to stop doing that.

So, any feedback on the game itself, the code, my half-assed art, etc. is welcome. Thanks!

http://www.muskratwaltz.com/other/NovaSxorp.zip

(Had to put it on my site because uploading to the forums isn't working. Should work fine, though.)

Uhfgood
03-10-2007, 06:45 AM
What do I do?

Seth
03-10-2007, 06:56 AM
Cool, I will take a look and post some comments on it later.

Btw, I think I just fixed the upload problem so feel free to try that again.

ZombieJesus
03-10-2007, 07:23 AM
Uhfgood, go to where you keep Novashell (I made this with the march 7 build, don't know about any incompatibilites with older ones). Now right (ctrl) click Novashell and select "Show package contents." This brings up a new finder window with all of Novashell's resources and things. Now go from Contents to Resources to worlds and drag the NovaSxorp file and NovaSxorp.novashell file into the worlds folder. Now start up Novashell and select NovaSxorp from the menu! You should then expect to be attacked by robots.

And also, since there is no documentation maybe I should mention that you move with the arrow keys or if you press space you can toggle between mouse and arrow control. And you shoot with W, A, S, D, Q, E, Z, and X (up, left, down, right, up left, up right, down left, and down right respectively).

whisperstorm
03-10-2007, 07:25 AM
Reminds me of Robotron - great first start!

harrio
03-10-2007, 07:20 PM
i thought i did it right, but i can't get it to play.

it shows up in the world list menu, but when i select it and press play the screen flashes quickly and i remain on the world list.

i know i'm doing something stupid.

Seth
03-11-2007, 06:34 AM
Hario,

For windows, running it easier, just unzip the files to any dir and then double click the .novashell file, should be all you have to do.

(after you unzip, NovaSxorp.novashell and NovaSxorp should be in the same dir!)

Nice work Zombie!

Ok, here are the fixes to the probs.


1) Upon the player dying I tried to make the game return to the Intro menu and let the player choose a new game or quit. I used the map manager's SetActiveMapByName function to open the level, but this results in an unresponsive screen. I did notice, however, that in that screen if you press escape you stay in Intro, but it becomes responsive again. Am I loading the map wrong? Is it incorrect to use SetActiveMap on Intro? This has me confused.

The reason it was unresponsive is it is really a "dumb" screen, the code that handles the menu would have to be jump started with:

//let's startup the intro menu
activeMenu = IntroMenu();

like it is in game_start.lua.

When you hit Escape, default behavior of the Escape key caused the world to be reloaded. (or, If no profile is loaded, it removes the current world and restarts so it will drop down to the "choose your world" base behavior.) This is redefinable in script if you poke around.

After a profile is loaded, you can't load another one without first removing the active one, so you should just use GetGameLogic:SetRestartEngineFlag(true); to restart, which will remove the profile and restart everything, leaving you at the intro menu.

This is an example of a game that could actually be done without the concept of profiles completely.. although I need to add a GetGameLogic:ShareData() that works like GetGameLogic:Data() except it's shared between profiles and even if profiles aren't loaded, for things like highscores. Hrm.


Also related to this is that at one point I intended to just stay in main on the player's death and start a new game instantly. This didn't work because I couldn't figure out how to reset the map (clear it of entities and such) because if I used UnloadMapByName on Main, Novashell crashed. Again I ask, am I doing that incorrectly or are you not supposed to unload Main maybe? All in all I am pretty confused by the map manager right now.

The reason for the crash is pretty tricky. In short, you shouldn't call UnloadMapByName() except at the global level, not from an entity. Or more accurately, not from an Entity that is ON the map that you want to delete. I'd like to put up an error message clearly explaining this.. but it's pretty tricky to calculate, as a collision in one entity can cause a string of callbacks across many maps...

So how can you run ReportPlayerDead as global instead of from an entity script?

Easy, change your player.lua's Onhit to this:


function OnHit(hitDamage)

if not GetSoundManager:IsPlaying(yelling) then
yelling = GetSoundManager:Play("audio/playerhit.ogg");
end

health = health - hitDamage;
GetEntityByName("Health"):RunFunction("SetText", tostring(health));
if health <= 0 then
//we don't want to recreate the level from here, because it would involve
//us, so we'll schedule it to happen at the global level in 1 MS
Schedule(1, C_ENTITY_NONE, 'ReportPlayerDead()');
end

end

The schedule will cause ReportPlayerDead() to be called by the system later, (at the end of the logic round) instead of now.

Change your ReportPlayerDead to this for "instant level restarts":


function ReportPlayerDead()

//if we wanted to go back to intro screen, this is the only way to get rid of the active
//profile

//GetGameLogic:SetRestartEngineFlag(true);

GetMapManager:UnloadMapByName("Main"); //because it's not persistent, basically we just
//throw away all changes that were made on it and force it to reload if we use it again

GetMapManager:SetActiveMapByName("Main"); //setting it also causes it to be loaded if needed
GetMapManager:GetActiveMap():SetPersistent(false);


//now that we've reloaded it, we'll have to set it to not be persistent again (a work
//around to not need to keep setting it would be setting it in the "master" files and using
//File->Save Map Now

//reset level stuff otherwise the player won't be created

levelNum = 0;
enemiesNum = 0;

LoadLevel();

end


2) This is actually also similar to the first one. When you are playing the game and press escape to return to Intro it works fine except that it tells me that I tried to call a nil value at some point in one of my scripts. It references a line in which I use RunFunction on an entity in Main. I'm guessing that Main had been unloaded when I set the active map to Intro, but by looking at my code I would think that it shouldn't even call that function after I've set the map to Intro.


Whenever a map is unloaded, the enemy's OnKill() would be run. It's not safe to assume any specific entity is active, in fact, the "Level" entity might have already been destroyed, so when it called ReportEnemyDead, (without really being killed by the player, it was just being deleted as the map was) certain things in there are failing, and further confusing things by calling LoadLevel() when it thinks all enemies are destroyed.

So, to fix this, remove ReportEnemyDead() from enemy.lua's OnKill() and add it to its OnHit, so we know it will only get called when the player actually kills him, like this:


function OnHit(hitDamage)

if not GetSoundManager:IsPlaying(damageSound) then
damageSound = GetSoundManager:Play("/audio/enemyhit.ogg");
end

health = health - hitDamage;


if health <= 0 then
ReportEnemyDead();
this:SetDeleteFlag(true);
end

end

With these changes it runs great.. although by holding down a key you can sort of cheat with rapid fire, probably want to put a delay on how fast you can fire.. :)

Oh PS, please download the latest novashell, I fixed a visual glitch that was making the bottom of your sprites show a little line sometimes.

PPS: Attaching big files fixed, here's a version with the changes made

harrio
03-11-2007, 06:30 PM
it confirmed...i'm an idiot, thanx for the help seth. worked like a charm when i used the right file.

hey zj, what are drawings/schematics in the background?

i cheated with rapid fire too, better fix that or robots beware.

i can't wait to get something up and running.

ZombieJesus
03-12-2007, 12:58 AM
Thanks Seth, that helps a lot! Now I can make it a little more complex than 1) Kill all the monsters. 2) See step one.

Harrio, the background is my idealized view of how circuit boards look. Pretty much I got it from seeing computer components and electronics in cartoons. I have some more backgrounds for it, but I'm going to make those show up once I get used to visual profiles.

Thanks for the positive feedback everybody!

nijineko
08-27-2007, 05:12 AM
hmmm, cannot seem to download to try it out. despite being logged in, it brings up a login page. when trying to login again, it just bounces to the same page, no download. =(

Eschar
09-03-2007, 06:50 PM
You are not alone, I am also incapable of downloading any attached files.

Edit: It works, now!

Excellent.

Pleng
03-15-2008, 12:55 PM
Awesome! Reminds me of those freeware Amiga games! :D

How did you make it so that the screen stays static (ie doesn't scroll when the player moves)?