don't click here

PROSONIC IS NOW OPEN SOURCE

Discussion in 'Fangaming Discussion' started by saxman, Jul 16, 2008.

Thread Status:
Not open for further replies.
  1. Nibble

    Nibble

    Oldbie
    I'm guessing the first object increments 'inertia' and sets 'timer_second' to zero, then the other object subtracts 2 from 'y_pos_pre'?

    Have you worked out the finer details of the scripting language? For example, if you declare a variable in an object block, is it local to that object, or does it become global so other objects can use it? And what's the program flow? When does object code execute? Every frame? Will it be possible to specify initialization, per-frame, and deletion code?

    Sorry for all the questions, but these kinds of details can become important later on.
     
  2. saxman

    saxman

    Oldbie Tech Member
    I'm going to break down your quote into sections to discuss it a bit easier.

    Interpretation of script:
    You're correct. The '++' is an increment, the '=' is a direct assignment, and the '-' subtracts the specified amount. Obviously it's heavily influenced from C/C++ coding. I simplified some things to make the scripting language a bit easier for me to support though, such as the lack of use for the '{' and '}' when making trees. When I use if/else statements, I end the whole thing with 'endif', much like BASIC does.


    Declaring variables:
    Unless things change in the future, this functionality isn't planned. All objects will have X number of pre-defined internal variables that the user can use. There should be plenty to work with. There will also be variables that will be global, so it will be possible to pass data between objects using the global variables.


    Program flow:
    For each frame (with 60 frames per second), it does the following...
    - Check keyboard inputs / demo sequence
    - Sync the timers if working with the first frame (player 1)
    - Clear screen buffers
    - Run Obj01() code (player 1)
    - Object memory management / run code for objects
    - Draw level and objects to screen buffers
    - Draw HUD to screen buffers
    - Process sound
    - Blit frame buffer data to larger buffer (blit larger buffer on the last player)
    - Update internal counters for various things
    - Check if level is inactive and reprocess variables if true
    - Repeat for other players if they exist

    The program flow I've outlined is probably isn't 100% accurate, but that's what I came up with going through the engine code very breifly. That should answer your question though.


    Other processes:
    The scripts will not be limited to running code for objects, but will also support functions that run every frame during gameplay, that run once during the boot-up of a level, and run once for the end or restart of a level.

    It isn't part of the plan, but I could end up allowing the scripts to handle the title screen, title card sequences, and other vital functions of that nature. That gets a little further ahead than I'm currently focusing on though. Right now, I'm just working with stuff that directly affects gameplay.
     
  3. The Taxman

    The Taxman

    Tech Member
    673
    7
    0
    Retro Engine & Related Projects
    Cool progress so far man, although is 'set' really necessary?

    e.g. 'set timer_second = 0' could just be written as:

    timer_second = 0

    It also seems a little strange to have 'set' with increment and subtraction stuff. Usually 'set' correlates with 'equal to', like you're setting one variable to equal something else.
     
  4. saxman

    saxman

    Oldbie Tech Member
    I thought about that too. The way my code is set up, it always starts by checking for a keyword. Once it finds the keyword, it can use any combination of things after that that I tell it to use, rather it be a constant, an operator, and so on. I used 'set' to let it know it needs to perform a math operation.

    But I think you're right, it does seem a bit awkward, and I may just add in some extra code to allow it to do the math operations without a keyword.
     
  5. roxahris

    roxahris

    Everyone's a hypocrite. Take my word for it. Member
    1,224
    0
    0
    Doing anything at all
    I'm wondering about that; why not have someting similar to this?
    Code (Text):
    1. var_moveframe = 15
    2. if ...
    3. ...
    4. var_moveframe ++ 1
    5. endif
     
  6. nineko

    nineko

    I am the Holy Cat Tech Member
    6,308
    486
    63
    italy
    Or use LET instead of SET, just like it is in Basic.
    Not many people know this, but the correct syntax for an assignment (in both QB and VB, afaik) is this:
    [LET] variable = expression

    Emphasis on the square brakets. LET is there, but it's optional.
     
  7. The Taxman

    The Taxman

    Tech Member
    673
    7
    0
    Retro Engine & Related Projects
    Yeah, LET seems like a good replacement IMO (although going the extra mile and adding the code so you can have just variable = expression would be better ;) )
     
  8. Shadow Hog

    Shadow Hog

    "I'm a superdog!" Member
    I think I've only seen one programming language that ever uses "let". And that was OCaml. God I hated OCaml.

    Personally I'm more into C/Java-styled variable declarations (ie: "foo = bar"), but I guess I can live with your method (ie: "let foo = bar") if I must.
     
  9. saxman

    saxman

    Oldbie Tech Member
    I took Taxman's suggestion and made it so if no keyword is used, it reads it as an expression. It works well. So it's just like C basically where you have the variable, then the operation, and finally the value (which can be a variable or a constant.) It supports all the operators found in C.

    Right now, I'm preparing to get if/else statements to compile. Those are going to be a bit tricky, but I have it planned out on paper exactly how I'm going to handle those. And you'll be able to make multi-layered if/then code the same way that any decent language allows you to do. Once I get if/else statements to compile, I'm going to try testing some script code in ProSonic to see about creating my first scripted object =)

    The plan is once I get the scripting support completed, I'll begin converting some objects from various Sonic games over so they run in ProSonic. I'm hoping to get some enemies in there and perhaps have a complete Emerald Hill Zone, much like what Taxman did with the DC demo he put out for Retro Sonic.
     
  10. Ultima

    Ultima

    Games Publisher Tech Member
    2,398
    1
    18
    London, England
    Publishing mobile games!
    Maybe you should include the option for dynamic compilation of scripts at runtime, for debugging. Having to compile the scripts every little change would be a big time sink compared to the program automatically compiling them when ran - especially on a decent development machine, and also leaves room for programmer error (forgetting to compile after a change has been made...)
     
  11. Rainer

    Rainer

    Member
    383
    0
    0
    I think probably the best language to use for scripting would be Lisp. I'm not being a fanboy, but it's the absolutely easiest out of all of them to parse. So just out of laziness Lisp would be the best option.

    Although in my opinion, C-style syntax is still an extremely good option, although you're probably doing unnecessary work in the process.
     
  12. saxman

    saxman

    Oldbie Tech Member
    I've looked into some different options. I particuarly wanted AngleScript to work in my engine, but I failed to ever get the thing to work. I think I looked at Lisp too at one point. I couldn't get anything to work because quite honestly, I'm just not very good with working with stuff that isn't my own.

    With an exception...

    Both my scripting language and parser are actually based on that used in Duke Nukem 3D. I followed that particular part of the DN3D source code step by step until I got to a point where I understood how it worked. From there, I branched off and started writing my own code. So it's a new language with some of my own ideas, but there's nothing really special about the method I go about making it work as I pretty much copied what was already done for me.

    I'm considering supporting both source and bytecode files, but supporting source files I consider to be a lower priority than bytecode files. Bytecode is an option I know some people will want to take to avoid having outsiders take code from their games and use it in other games. That at least limits what other people can do with it to an extent, whereas having the source files they can do anything they want with it.

    But I agree that it may be easier for updating things to simply have the engine compile the source files itself each time you run it. I'll consider it.
     
  13. Conan Kudo

    Conan Kudo

    「真実はいつも一つ!」工藤新一 Member
    478
    1
    18
    Why don't you support <a href="http://en.wikipedia.org/wiki/Lua_(programming_language)" target="_blank">Lua</a> and/or Python?

    Lua seems to be very popular with videogames, and Python is pretty popular overall...
     
  14. saxman

    saxman

    Oldbie Tech Member
    Tried it. I've had a lot of suggestions made over the years, but none of them worked out for me. As I said, I'm not good with handling someone elses code, but I made headway borrowing and modifying code from DN3D.
     
  15. saxman

    saxman

    Oldbie Tech Member
    Not sure why I'm doing this other than I think it's kinda cool to look back at old stuff and see how it all changed through time. I have uploaded every single backup I have ever made prior to the 08/22/08 release date. There's 27 in total, including the 08/22/08 release version.

    http://prosonic.4shared.com/

    You may also find it surprising how fast I had to work during June, July, and August to get the engine ready for a public release. I tried for years to get the physics right, and you can see all my attempts at that link. Engine 1 was in development from 12/15/05, to sometime around November or December in '06. After that, I rewrote it from ground up -- that's Engine 2, the current engine I'm working with. But anyway, there you have it.



    On a note regarding what's going on now, I'm still working with the scripting language. There's plenty of progress being made, but I'll discuss all of that when the time is right.
     
  16. saxman

    saxman

    Oldbie Tech Member
    Update on the scripting support...

    [​IMG]

    Supported as of May 25th are if/else statements, arrays (for assignment statements only, at least right now), playing sound and music, and text output (shown in the screenshot above where it has "running ...")

    It supports code specific to any object from 1 to 255, and it supports special functions that run at specific times -- one every frame before running objects, one every frame after running objects, and one that runs once when a level is loading.

    I'm planning sprite/animation output soon. I also have an idea on how to script enemies and other active objects in a "simple" manner. I've been studying the enemies in Sonic 2 and followed their patterns and how they function, and I realized how amazingly NOT complicated they are. So I'm considering making objects have states, where you can define a movement range, speed of movement, and other little things. Then you would simply tell the script to set the state, and the engine would run the code for that state, figuring out how to move the enemy, if it should detect collision or not, etc. That would be the biggest challenege of this scripting language. It would make designing enemies and other kinds of active objects for newbies very easy to do I believe.



    Here's some script code I'm testing the engine with currently:
    Code (Text):
    1. (GAME.TXT)
    2. /*
    3.  ==========================================
    4.  ProSonic script test file
    5.  Programmed by Damian Grove
    6.  
    7.  Compile using the ProSonic script Compiler
    8.  ==========================================
    9. */
    10.  
    11. include&nbsp;&nbsp;&nbsp;&nbsp; "defs.txt"
    12.  
    13.  
    14. function LEVELSTART
    15. &nbsp;&nbsp;&nbsp;&nbsp;resetsound
    16. &nbsp;&nbsp;&nbsp;&nbsp;d0 = zone
    17. &nbsp;&nbsp;&nbsp;&nbsp;d0 % 3
    18. &nbsp;&nbsp;&nbsp;&nbsp;d0 ++
    19. &nbsp;&nbsp;&nbsp;&nbsp;playfm d0 0 0
    20. &nbsp;&nbsp;&nbsp;&nbsp;
    21. &nbsp;&nbsp;&nbsp;&nbsp;if zone == 16
    22. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;playpcm 2 1 0
    23. &nbsp;&nbsp;&nbsp;&nbsp;endif
    24. endfunction
    25.  
    26.  
    27. function INGAME1
    28. &nbsp;&nbsp;&nbsp;&nbsp;// do stuff before running objects
    29. &nbsp;&nbsp;&nbsp;&nbsp;textout 160 0 0 "RUNNING INGAME1"
    30. endfunction
    31.  
    32.  
    33. function INGAME2
    34. &nbsp;&nbsp;&nbsp;&nbsp;// do stuff after running objects
    35. &nbsp;&nbsp;&nbsp;&nbsp;textout 160 20 0 "RUNNING INGAME2"
    36. endfunction
    37.  
    38.  
    39. object OBJ_BRIDGE
    40. &nbsp;&nbsp;&nbsp;&nbsp;textout 160 10 0 "RUNNING OBJ_BRIDGE"
    41. &nbsp;&nbsp;&nbsp;&nbsp;if p.ring_count < 16
    42. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o.user[p.ring_count] = p.ring_count
    43. &nbsp;&nbsp;&nbsp;&nbsp;else
    44. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d0 = p.ring_count
    45. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d0 % 16
    46. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.score = o.user[d0]
    47. &nbsp;&nbsp;&nbsp;&nbsp;endif
    48. &nbsp;&nbsp;&nbsp;&nbsp;
    49. &nbsp;&nbsp;&nbsp;&nbsp;if p.ring_count == 8
    50. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d0 = p.extra_life_flags
    51. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d0 & 1
    52. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if d0 == 0
    53. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.extra_life_flags | 1
    54. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.life_count ++
    55. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif
    56. &nbsp;&nbsp;&nbsp;&nbsp;elseif p.ring_count == 16
    57. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d0 = p.extra_life_flags
    58. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d0 & 2
    59. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if d0 == 0
    60. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.extra_life_flags | 2
    61. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.life_count ++
    62. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif
    63. &nbsp;&nbsp;&nbsp;&nbsp;endif
    64. endobject
    Code (Text):
    1. (DEFS.TXT)
    2. /*
    3.  ==========================================
    4.  ProSonic script test file
    5.  Programmed by Damian Grove
    6.  
    7.  Compile using the ProSonic script Compiler
    8.  ==========================================
    9. */
    10.  
    11.  
    12. // Generic game functions
    13. define INGAME1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp; // runs before objects
    14. define INGAME2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp; // runs after objects
    15. define LEVELSTART&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3
    16. // define LEVELEND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4
    17. // define TITLECARD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5
    18.  
    19.  
    20. // Objects
    21. define OBJ_PLAYER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp; // *
    22. define OBJ_PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp; // *
    23. define OBJ_SPIRAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp; // EHZ, MZ
    24. define OBJ_BRIDGE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17&nbsp;&nbsp;// EHZ, HPZ
    25. define OBJ_SPEED&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;27&nbsp;&nbsp;// CPZ
    26. define OBJ_RING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 37&nbsp;&nbsp;// *
    27. define OBJ_FAN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63&nbsp;&nbsp;// OOZ
     
  17. Yuzu

    Yuzu

    Member
    2,548
    51
    28
    Holy crap! I didn't expect the scripting to progress this quickly, the code makes sense and I'm not even that skilled in programming languages(I'm decent at C++, same with ASM). I'm looking forward to when work on the multiplayer starts. Keep up the work! ;)
     
  18. saxman

    saxman

    Oldbie Tech Member
  19. GasparXR

    GasparXR

    I'm back! Member
    Just out of curiosity, if you're going to be creating an Event Editor (like in MMF), will we be able to switch between a design editor and a script editor when editing an event or object? (much like in Visual Basic when editing forms)
     
  20. muteKi

    muteKi

    Fuck it Member
    7,851
    131
    43
    Very sexeh! I'm already thinking about using this to make missiles that spawn missiles based on how long you spend in a level.
     
Thread Status:
Not open for further replies.