Results 1 to 8 of 8

Thread: I can't code

  1. #1
    Squire Cobra's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    16

    Unhappy I can't code

    To say I'm no coder would have to be an understatement. The last time I tried to actually code a game was back on the Commodore 64... and well the less I say about that the better.

    I'm trying to create a commercial game, but after a lot of frustration it looks like I'm going to have to ask for help. Hopefully once I'm up to the actual gameplay aspect it'll be easy enough for me to build off of the already great examples provided with NovaShell.

    What I have so far, is the opening logo, intro, and the title.
    I was successful to this point by going back over the tutorial, reading the scripting reference, and exploring the examples. But ultimately I seem to be hopeless at scripting. What I was able to do is make it so if you press escape, you'll skip past the intro to the title screen.

    What needs to be done,
    I want it so if you push space on the logo screen it'll jump to the intro, push space during the intro it'll jump to the title. And finally, for the title screen I want space to jump to Main and unbind itself so it can be reassigned for shooting in-game.

    It is great I got escape to take the player right to the title, but now if they then press escape on the title screen I want a dialogue to pop up asking them if they are sure if they want to quit the game. Also in game, when they are playing I want pressing escape to pop up a dialogue asking them if they are sure they want to quit to the title screen.

    Any help would be great, so I have attached my game.
    Attached Files Attached Files

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Hey Cobra,

    That's an excellent intro, can't wait to see it with audio.

    First, playing with your intro helped me to find some bugs with world loading/unloading... you should upgrade to the latest version for my scripts to work right. (I just put one up ten minutes ago)

    In your game_start.lua, you should remove the intro_menu.lua stuff. You aren't using it at all in what you currently have, it's just confusing things by making so clicking on image elements will make them fall off the screen.

    After commenting them out that would look like this:

    Code:
    //RunScript("intro/intro_menu.lua");
    
    //let's startup the intro menu
    //activeMenu = IntroMenu();
    Or you could just delete those lines.

    Next, you can get the rest of what you need just by making some more modifications to the game_start.lua. Replace your OnKeyEscape function in it with this one:

    Code:
    function OnKeyEscape(bKeyDown)
    
      if (bKeyDown) then
      	local curMapName = GetMapManager:GetActiveMap():GetName();
    		LogMsg("Right now we're sitting on map " .. curMapName);	
    		
    		if (curMapName == "Intro") then
    			//they are on the intro opening credits, let's skip them to prologue
    		  GetMapManager:SetActiveMapByName("Prologue");
    		end
    
    		if (curMapName == "Prologue") then
    			//they are on the prologue now.. skip to the title screen
    			GetMapManager:SetActiveMapByName("Title");
    		end
    		
    		if (curMapName == "Title") then
    			//they are on the title screen now
    		  
    		  //if we wanted to just cycle back to the intro again, uncomment below and comment out the
    		  //InitQuitMenu(); command
    		  
    		  //GetMapManager:UnloadMapByName("Intro"); //force it be refreshed, like new
    		  //GetMapManager:UnloadMapByName("Prologue"); //force it be refreshed, like new
    		  //GetMapManager:UnloadMapByName("Title"); //force it be refreshed, like new
    	  	  //GetMapManager:SetActiveMapByName("Intro");
    		  
    		  //But instead, let's just ask them if they want to quit
    		  InitQuitMenu();
    		end
    	end
    
    	return false; //don't process any other callbacks for this keypress
    end
    Also, add these two new functions to the same file, these are for handling the quit game confirmation from the main menu when escape is hit. (See where we run InitQuitMenu() in the function above?)

    Code:
    //ask the player if they really want to quit the game
    function InitQuitMenu()
    
    	local entChoice = CreateEntitySpecial("ChoiceDialog", "callback=OnQuitMenuResponse;title=Quit the game?");
    	
    	entChoice:Send("add_choice|Quit game|quit");
    	entChoice:Send("add_choice|Back|back");
    	entChoice:Send("activate");
    	
    end
    
    function OnQuitMenuResponse(text, key, dialog) //dialog is passed as a SpecialEntity
    
    	if (key == "quit") then
    			GetGameLogic:Quit(); //really quit the game
    		end;
    
    	//otherwise, nothing will happen.		
    
    end
    That should do it. Getting a handle on novashell scripting is a bit tricky, hang in there.
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Squire Cobra's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    16

    Smile

    Wow, thank you so much once again you have been a HUGE help.
    Not only for making this game, but I intend to have the same kind of setup on future games as well.

    Thank you for the compliment, I'm glad you like the intro

    I tried to comment out the intro_menu, but then the when I tried to start up the game I just got a blank screen

    Once again thanks so much, now I can move onto the next step. (music and sfx are the final step, for now I just listen to my own music while I work on the game )

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    I tried to comment out the intro_menu, but then the when I tried to start up the game I just got a blank screen
    Oops! My mistake, I forgot that the intro_menu does one thing that is needed - to load a map to start out with.

    About where you commented out the intro menu stuff, just add this one line:

    Code:
    GetMapManager:SetActiveMapByName("Intro");
    This will cause that map to be loaded and made active, the blank screen was because no map was loaded.
    Seth A. Robinson
    Robinson Technologies

  5. #5
    Squire Cobra's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    16

    Default

    Thanks again, yep it works fine now. Now I have the menu things are also a lot easier than pressing Alt+F4 to quit too I was able to get everything the way I wanted it thanks to your help I'm now going to try and do a character select screen, hopefully I'll be able to manage this one.

    One thing that I think is really impressive with NovaShell is its handling of images. Not just preserving transparency but how you can move them about. Especially the fact it is using the actual image at all times, so when I wanted to make a few visual fixes. All I had to do was open the image edit it, save it, and all done.

  6. #6
    Squire Cobra's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    16

    Default

    Sorry to be such a bother and ask for help again, I'm sure I'll get the hang of the scripting side of NovaShell given time. I probably should of gone with a platform game idea I had for my 1st game, but I guess I have to learn somehow.

    I know exactly what I want to happen on the character select.

    There are 3 characters to choose from.
    So I want there to be a hidden value that can rage from 0-2.
    It should start at 0, and by pushing left or right will move it up and down between the values.

    When the value is 0, the 1st character is highlighted as they currently are, and pushing space at this time will load up map Level1A.

    When the value is 1, the 2nd character is highlighted with the selector entity, and pushing space at this time will load up map Level1B.

    When the value is 2, the 3rd character is highlighted with the selector entity, and pushing space at this time will load up map Level1C.
    Attached Files Attached Files

  7. #7
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Hey Cobra - Check the latest Novashell version, in its "Low Res" example, in its gui/main_menu.lua it does something very similar to what you need.

    It allows the player to use the arrow keys to change g_curSelection from 0 to 2, and then updates visuals based on this.

    The key is to separate the input/var changing from the visuals, so first make sure the keys/input are working with LogMsg(), then you can move on to making the visuals match. (In the LowRes example, that happens in MainUpdateVisuals() )
    Seth A. Robinson
    Robinson Technologies

  8. #8
    Squire Cobra's Avatar
    Join Date
    Mar 2008
    Location
    Australia
    Posts
    16

    Default

    Awesome, I'll check it out now. As always you have my thanks.

Similar Threads

  1. Code::Blocks
    By ART_Adventures in forum Official ClanLib SDK Forums
    Replies: 6
    Last Post: 01-14-2010, 12:00 AM
  2. [img] code in signatures or images
    By aGig in forum RTsoft Tavern
    Replies: 0
    Last Post: 01-31-2007, 02:52 AM
  3. Submit Code to Clanlib
    By ART_Adventures in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 09-26-2006, 10:25 PM
  4. registration code?
    By in forum RTsoft Tavern
    Replies: 4
    Last Post: 09-05-2004, 12:38 AM
  5. Source Code
    By Wavesphere in forum Dink Smallwood HD
    Replies: 4
    Last Post: 10-27-2002, 09:13 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •