Another letter for you.
Point 1.
I have mentioned the help several times, do you know where to find it? Start menu, Programs, The Game Creators, Dark GDK, Documentation, Information. If you can't find it there, the help file is installed here: <directory where you installed Dark GDK, default is Program Files, The Game Creators, Dark GDK> / Documentation / Dark GDK.chm.
I seriously recommend to open that and look through the available commands of the language and their descriptions. Even if you don't catch everything at first sight, but you should be aware what are the elements you can use to build your program with. They will come to mind when you need them. Sorry if you already know this, but I have a feeling you haven't looked at the help files yet.
Point 2.
Code for "displaying things on the screen": easy. Use the dbText function for displaying text. If you need to display integer or float values, convert them to text with dbStr function. To display an integer value named Speed at the top left of the screen, you use:
dbText(0, 0, dbStr(Speed));
The only trick is that in the beginning of the program (before the main loop, in the initialization part), you need to include this:
otherwise the text would be behind the sprites, so you won't see it.
In the attached file, I have included these instructions for you. (Other corrections are described below.) Copy-paste the whole text into the Main.cpp.
Point 3.
If you expected your variables to "carry over" from the main loop to inside a function, then you need some more learning about the C++ programming language as well, not only Dark GDK. In fact, the main advantage of functions is that they represent a separate "naming space" from your main program. You can use local variables without worrying about ruining the variables of the main program or of any other function. You can use the same-name variable in several functions and they will be all different variables! If you want to pass a variable to a function, then you can either: (a) use function parameters and pass your values as parameters, or (b) define your variables OUTSIDE the main loop. That way, they will be global variables and they will really "carry over", that is, they will be accessible throughout the whole file. (At least, as long as one of the functions does not define a local variable with the same name.)
I praise your initiative to organize the code into different parts, which is a good thing to do, but the implementation can be improved.
Perhaps you could have a look at a few C++ language descriptions, for example
http://www.cplusplus.com/doc/tutorial/ or
http://msdn.microsoft.com/en-us/beginner/cc305129.aspx or even a good book.
For the time being, I attached for you the corrected code, which can at least be compiled. I moved your global variables outside the main function.
Point 4.
Sprite display: The problem with the dbPasteSprite that you tried to use here is that it does not actually create the sprite, it only displays an already created sprite. Therefore it should be used inside the main loop, because if you don't paste the sprite every frame, then it will not appear at all. It is not enough to paste it once in the beginning.
Anyway, I suggest you to ignore the idea about pasting sprites and go back to your previous method which worked just fine, with the only exception that you don't need to reload the image. In the attached code, I pasted back your previous sprite-making lines, only with the re-loading line commented out. Pasting the sprite is an alternative display method and I suggest don't use two different methods in the same program, unless you have a really good reason to. Not even mentioning: don't change what works.
Point 5.
There were some suggestions in my above posts, which have not yet been taken into account in this code:
- I still uphold the idea to redesign the code using only one speed variable instead of two.
- The correction to ensuring that a variable stops changing at zero.
- The idea about checking if the sprite collided from above or from the side.
Point 6.
Style: It may be personal taste, but I find the code a bit difficult to read when you write one-line instructions into two lines. For example, the satement:
should be:
I use the several-line form only when the if contains several instructions which are grouped by the {} brackets.
A last request: next time, it is enough to pack your code files (currently, it is only Main.cpp as long as you don't create other include files) instead of the whole project. I already have your pictures from the previous downloads, and just to look at the code, it's not necessary to download a 9 MB zip file.
Well, I think that gives you enough to think about for a while.