Jump to content

Czar

Members
  • Content Count

    445
  • Joined

  • Last visited

  • Days Won

    13

Posts posted by Czar

  1. As a long time Delphi developer who has managed to avoid Javascript, HTML and CSS I found the learning curve for SMS steeper than expected.

     

    If SMS is billed as similar to Delphi then that is a misconception. For example, I have found that CSS understanding is crucial to making a decent app. Also understanding how a web page builds up is also important, and I am not sure I still have a grasp of that.

     

    The developers are obviously highly skilled and very talented but I believe they are over estimating the average user's ability to grasp concepts that are not explicitly explained.

     

    I would love to see documentation/website/blogs be more coherent and available in a single place.

     

    Finally, I would love to see a few thousand more users ;) Seriously, this is a brilliant product and I think it would be worth having a robust discussion as to why the take up hasn't been as good as it should be. I know I am only a user, and I have no vested financial interest in more users, but I intend to use SMS for some major development and a large user base means, more support, examples and greater likelihood of the product continuing to be developed/maintained.

  2. Notice how the post above this one is bunched up?

     

    this is how it is supposed to look.

     

    A couple of other issues I have noticed.

     

    When you enter text and "post" the return characters seem to be removed. All of the text is bunched up. If you then edit and post again the formatting remains.

     

    Also I am sure there used to be a widget at the to of the edit box to allow adding in post, code, image tags etc. Can that be restored?

  3. A couple of other issues I have noticed.

     

    When you enter text and "post" the return characters seem to be removed. All of the text is bunched up. If you then edit and post again the formatting remains.

     

    Also I am sure there used to be a widget at the to of the edit box to allow adding in post, code, image tags etc. Can that be restored?

  4. When I picked up Delphi 2 many many years ago my main goal was to program games. Purely as a hobby as I never intended to program for a living.

     

    For many years I made games using DelphiX and later DanJetX and OmegaDX9. Smart Mobile Studio represents an awesome opportunity to create games and animated graphics for browsers, tablets and phones. Initially I thought it would be a breeze converting some of my older games to SMS but I quickly ran into a myriad of challenges. Mainly due to my lack of understanding.

     

    I set about trying to make a demo that demonstrated techniques that I need in order to port some of my games. First I tried running as many demos as I could but all of them lacked elements of what I needed. I found the missile command demo very useful although due to a lack of documentation it can be difficult to understand certain parts of it. The Missile Command demo lacked a number of important elements. There was no keyboard interaction and none of the sprites were being rotated or otherwise manipulated.

     

    I have managed to solve my challenges because Jon and others, here on the forum, are patient enough to answer some of my questions. For that reason I decided to post my Game Demo here and also explain a few of the challenges that I encountered so that others can learn from it.

     

    gameshot.jpg

     

     

    Canvas vs. Form

    You can create a game in either canvas mode or using a tW3form. The canvas is faster and similar to a DirectX surface and the Form is the equivalent of using a Delphi Form with VCL components. Use the canvas.

     

    My Requirements

    SpriteSheet - the easiest way to animate a sprite is to use a spritesheet that contains all the animation frames.

     

    spritesheet1.png

     

    Rotation - This was a real bugbear for me. How to rotate the image on the screen. It turns out to be pretty simple but there were no examples available that demonstrated this techinque.

     

     

    Here is an example. The spritesheet is 3x3, i.e., there are 9 cells of animation. The current cell is drawn to the canvas. In this code the missile is drawn with the ability to be rotated. First we save the canvas's current settings. We then translate the point of origin to the centre of the image (cell). Each cell is 32x32 pixels so we step in 16 from the left and top. Now we rotate to the current angle and draw the image to the screen. Finally we restore the canvas to its saved state.

     

    laser.png

     

    var missile : TMissile;

    for missile in FMissiles do

    begin

    var idx := missile.Frame mod 9;

    Canvas.Save;

    Canvas.Translate(missile.x+16, missile.y+16);

    Canvas.Rotate(missile.ang);

    canvas.DrawImageF(FImgMissile,

    (idx mod 3)*32, (idx div 3)*32, 32, 32,

    -16,

    -16,

    32, 32);

    Canvas.Restore;

    end;

     

    note: the graphics resources appear to be case insensitive when you run from the IDE. However, make sure you use the correct case when referencing the graphics files otherwise you will have errors when you open the index.html on your website.

     

    Keyboard - the game examples that I found were all mouse friendly and did not require keyboard interaction. For my demo I want to be able to move a spaceship around using the arrow keys and be able to fire using the space bar.

     

    It turns out that the keydown and keyup events are not functioning correctly in SMS. I had to use Sascha's work around to get those events to work

     

    // keydown doesn't work at the present time this little work around solves the problem

    asm

    window.onkeydown=function(e)

    {

    TCanvasProject.KeyDownEvent(Self,e.keyCode);

    }

    window.onkeyup=function(e)

    {

    TCanvasProject.KeyUpEvent(Self,e.keyCode);

    }

    end;

    KeyDownEvent(0);

    KeyUpEvent(0);

     

    It is possible to respond to the keys in the keydown event. The problem is when the player is holding down the space bar to shoot and then they hit one of the arrow keys. Now the spacebar is no longer sending a keydown event. The work around is to store when a key goes down and when it comes back up. If the player holds down the spacebar the Shooting boolean is set, when they let go the keyup event sets the shooting boolean back to false. This system works nicely.

     

    I based my demo on the Missile Command demo as it was nicely set up and I could learn some new programming techniques. However, unlike that demo I did not want my Game Demo to be limited to a certain Frame Per Second. Instead I used the LastFrameTime to calculate distances etc. So all sprites move on a basis of pixels per time.

     

    I hope this Games Demo helps people over come some basic challenges and I would be keen to hear feedback.

     

    Note: I am using current beta RTL - unsure if it will compile with older RTL.

    GameDemo - live

    GameDemo.zip

  5. I am unable to clear the notifications from the forum.

     

    If I tick the notifications and click "mark as read" I get an error

     

    "Sorry, but you do not have permission to use this feature. If you are not logged in, you may do so using the form below if available. "

     

    Obviously I am logged in when this message appears.

  6. I will make a simple demo later but for now I will just post the relevant bit of code

     

    Canvas.Save;

    Canvas.Translate(FPlayer.x+25, FPlayer.y+25);

    Canvas.Rotate(FPlayer.ang);

    canvas.DrawImageF(FImgPlayer,

    idx*49, 0, 49, 49,

    -25,

    -25,

    49, 49);

    Canvas.Restore;

     

    Save the canvas before you start mucking around with it. Translate the origin point to where you want to draw the image. Rotate the canvas, draw the image and restore the canvas.

  7. I have been working on Game Canvas project

     

    TCanvasProject = class(TW3CustomGameApplication)

     

    I figured that this would be the best solution to make a game. However, I am running into some annoying limitations.

     

    I have my player image

     

    FImgPlayer : TW3Image;

     

    And I draw it to the canvas using the handle

     

    canvas.DrawImageF(FImgPlayer,

    idx*49, 0, 49, 49,

    FPlayer.x,

    FPlayer.y,

    49, 49);

     

    Now the problem..

     

    I would like to draw a rotated version of the image. I have checked as much as I could and I cannot find any draw functions that allow rotation.

     

    So am I missing something? How do I draw a rotated version of the image?

    Or it is there better solution for making games that allow the flexibility requited to scale and rotate images/sprites?

     

    Are there any demos that show this?

  8. Hi Guys,

     

    I am currently working on porting a Delphi game to SMS and I ran into the same problem that I ran into five years ago.

     

    Namely the gameview.onkeydown/up/press events don't work.

     

     

    I have used Jascha code again to solve the problem but I am hoping that this issue could be resolved in the upcoming RTL update as it is very confusing to have a seemingly obvious way to handle keyboard input and yet it doesn't work.

  9. I tried looking for this topic as I am sure I am not the only who finds this frustrating. However, I couldn't find a thread.

     

    If I have IDEs open, one with example code and one with my project. I can only seem to execute the code from one IDE. The other throws an error saying socket in use etc.

     

    I tried looking in project options but I couldn't discover a work around.

     

    Is it possible to execute multiple projects? If so how do we set it up?

  10. From facebook today

    "It's been a long wait, but we are working to get the next-gen RTL into your hands within the next 30 days. The node.js database driver is due after the update, giving you easy access to mongoDB, sqLite and Firebird.

    The changelog for this update is now more than 15 A4 pages long - so this is without a doubt the biggest and most substancial update Smart Pascal has ever seen."

  11. Hmm, might be more difficult than I first thought. I expected the memo to allow HTML tags etc. 

    My main reason for writing a bespoke version is to 

    1. allow data to be saved as a "file" to a home director online
    2. allow tutors to add comments or suggestions to the students writing

  12. Bit of a long shot. I am thinking of making  a basic text editor, word processor application. I am just wondering if there is a sample already available?

     

    I have had a search and came up empty. So I am looking for something with similar abilities as the widget I am currently typing in.

  13. What I think I might do is place our own common units into the library folder and then use SVN to keep the team up to date.

    I will have a look at your suggestions also once we get started on our team efforts.

  14. Thanks Nico, I did try a search on virteq and got no hits.

     

    I don't see a solution in that thread. I am unsure why it has recently started - I haven't had the pop previously

  15. Just noticed IPB skin is virteq

    And I have googled and found this. Not sure how it helps but keen to see the end of the popups - they are annoying. ;)
     

    The site skin has:

    1. http://virteq.com/profile_picture.png

    Buried all over the place as a branding of some sort.  Their site is whacked, now asking for authorization to access it, so when the URL is called, you get the authentication dialog.

     

    You need to strip that out of all of the CSS to make the dialog disappear, or do a local DNS redirect to dead-end it someplace.

     

    I removed the offending code.  Tested on Edge and do not see the popup anymore.

    The code was a Javascript for embedding the skin creator's logo and name (for credit).

    If anyone sees similar popups anywhere, please respond to this topic and I'll remove it.

    I'll be looking through the code to see if I can find it anywhere else, but I only found one place in a global template, which I removed.

     

    I'm guessing their site got compromised or they implemented some new authorization scheme that extended to all external references.

    Any site using their skins (not just this site, nor just this skin of theirs) will be impacted by whatever they did.

     

    Again, just to repeat, the skin was a verified one to use for this software.  There was no hacking of this site.

×
×
  • Create New...