CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: Unicorn on April 21, 2016, 05:12:43 AM

Title: Jumping/Parkour [TI 84+ CE] [C]
Post by: Unicorn on April 21, 2016, 05:12:43 AM
I've been experimenting with C again, and I think I'm going to attempt to create some sort of shooting game. Not sure how this going to work, but if it gets to complicated, I'm gonna make it into something of a level by level jumping/parkour/portal type thing (without portals)

So here's a screenshot...

(https://usercontent.irccloud-cdn.com/file/9Hv0J0Ah/Something.gif)

Tell me what you think!
Title: Re: A Game
Post by: Dream of Omnimaga on April 21, 2016, 03:39:18 PM
I always liked how the screen looked like in 8 bits mode in the TI-OS. :P

But more seriously, I'm glad that you plan to make some Zombie Gun clone or some run and jump game. Good luck @Unicorn and feel free to ask for C help on the forums if you need any. :)
Title: Re: A Game [TI 84+ CE] [C]
Post by: Dudeman313 on April 21, 2016, 07:46:43 PM
That looks cool! :D

Maybe a bouncer weapon could be an actual thing in the completed game?
Title: Re: A Game
Post by: Unicorn on April 22, 2016, 05:43:43 AM
Yeah, hopefully I can do this!

So I've decides to doaway with the zombie gun idea, I'm gonna create a jumping style game, with different blocks that do different things. Once I get deaths and things working, I hope to maybe build a level sditor of sorts... We'll see...
Title: Re: A Game
Post by: Dream of Omnimaga on April 22, 2016, 05:53:44 AM
Maybe it could be like Ztrumpet's Jump game for the 84+? It was quite simple to start with as a new language project. You could add power-ups later.

Also, everytime I see this topic, I think of "The Game", then I lose :P
Title: Re: A Game
Post by: Unicorn on April 22, 2016, 06:02:01 AM
Quote from: DJ Omnimaga on April 22, 2016, 05:53:44 AM
Maybe it could be like Ztrumpet's Jump game for the 84+? It was quite simple to start with as a new language project. You could add power-ups later.
Yeah, I've seen that, but the only thing is that I don't know how to do side scrolling... Otherwise, I would do that...
Quote
Also, everytime I see this topic, I think of "The Game", then I lose :P
Haha, I'll change that now :P
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on April 22, 2016, 06:34:26 AM
That's good. Clear topic titles are your friend anyway :)

ALso feel free to make a side-scrolling help topic if you need help on that. Perhaps scrolling help might be better, but make sure to do your homework first (eg checking Google in case you find something relevant there first)
Title: Re: Jumping/Parkour [TI 84+ CE] [C]
Post by: Dudeman313 on April 22, 2016, 06:26:06 PM
Oh, that's a much better title. :P

Quote from: Unicorn on April 22, 2016, 05:43:43 AM
Yeah, hopefully I can do this!

So I've decides to doaway with the zombie gun idea, I'm gonna create a jumping style game, with different blocks that do different things. Once I get deaths and things working, I hope to maybe build a level sditor of sorts... We'll see...
Alright. Level editors are always welcome. :)
Title: Re: Jumping/Parkour
Post by: Unicorn on April 28, 2016, 04:52:12 AM
Progress! Colossion and lava (?) work, somewhat. I haven't figured out a way to check the entire rectangle for colors, so if you have suggestions, please post :)

Screenshot:
(https://usercontent.irccloud-cdn.com/file/oh4dulMc/Something%21.gif)



//--------------------------------------
// Program Name:
// Author:
// License:
// Description:
//--------------------------------------

/* Keep these headers */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

/* Standard headers - it's recommended to leave them included */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <graphc.h>
#include <keypadc.h>
#include <debug.h>
/* Other available headers */
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h

/* Put your function prototypes here */

/* Put all your globals here. */
int x = 1, y = 149, a = 1, key, key1, keyPress, getPixel;
bool jump = false, shoot = false;
void main(void) {
gc_InitGraph();
gc_SetColorIndex(37);
gc_FillScrn(0);
gc_NoClipRectangle(0,162,350,350);
gc_SetColorIndex(245);
gc_NoClipRectangle(40,162,16,16);
gc_SetColorIndex(59);
gc_NoClipRectangle(x,y,6,12);
gc_SetColorIndex(37);
gc_NoClipRectangle(100,146,16,16);
while (kb_ScanGroup(kb_group_6) != kb_Clear) {
gc_SetColorIndex(59);
gc_NoClipRectangle(x,y,6,12);
      if (keyPress % 15 == 0) {
        if (key & kb_Left && y > 149 && gc_ClipGetPixel(x-1,y) != 37) {
        gc_SetColorIndex(0);
        gc_NoClipRectangle(x,y,6,12);
            x = x-4;
        }
        if (key & kb_Right && y > 149 && gc_ClipGetPixel(x+7,y) != 37) {
        gc_SetColorIndex(0);
            gc_NoClipRectangle(x,y,6,12);
            x= x+4;
            getPixel = gc_ClipGetPixel(x, y+14);
dbg_sprintf(dbgout, "Get_Pixel Color: ");
dbg_sprintf(dbgout, "%d\n", getPixel);
          }
        if (key & kb_Left && y < 150 && gc_ClipGetPixel(x-1,y) != 37) {
        gc_SetColorIndex(0);
        gc_NoClipRectangle(x,y,6,12);
            x = x-2;
            getPixel = gc_ClipGetPixel(x, y+14);
dbg_sprintf(dbgout, "Get_Pixel Color: ");
dbg_sprintf(dbgout, "%d\n", getPixel);
        }
        if (key & kb_Right && y < 150 && gc_ClipGetPixel(x+7,y) != 37) {
        gc_SetColorIndex(0);
            gc_NoClipRectangle(x,y,6,12);
            x= x+2;
            getPixel = gc_ClipGetPixel(x, y+14);
dbg_sprintf(dbgout, "Get_Pixel Color: ");
dbg_sprintf(dbgout, "%d\n", getPixel);
        }
        if (key & kb_Up && y > 147 && gc_ClipGetPixel(x,y-1) != 37) {
        jump = true;
        getPixel = gc_ClipGetPixel(x, y+14);
dbg_sprintf(dbgout, "Get_Pixel Color: ");
dbg_sprintf(dbgout, "%d\n", getPixel);
        }
        if (jump == true) {
        gc_SetColorIndex(0);
        gc_NoClipRectangle(x,y,6,12);
        y = y-2;
        }
        if (y <= 122) {
        gc_SetColorIndex(0);
        gc_NoClipRectangle(x,y,6,12);
        jump = false;
        }
        if (jump == false && gc_ClipGetPixel(x+3,y+13) != 37) {
        gc_SetColorIndex(0);
        gc_NoClipRectangle(x,y,6,12);
        y= y+3;
        }
}
if (gc_ClipGetPixel(x+3,y+14) == 245)
break;
keyPress++;
key = kb_ScanGroup(kb_group_7);
    key1 = kb_ScanGroup(kb_group_1);
}/* Fill in the body of the main function here */
    gc_CloseGraph();
pgrm_CleanUp();
}
/* Put other functions here */
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on April 28, 2016, 06:27:47 AM
GLad you are making progress. :) Hopefully you can manage to fix some of the display bugs in future updates :) (for example when the guy falls slightly inside the ground)
Title: Re: Jumping/Parkour
Post by: Unicorn on April 28, 2016, 06:31:26 AM
Yup. That has something to do with the coordinates system I'm using for physics, but the landing will be getpixel soon enoigh.

And as Mateo said on irc, I have some optimizing to do :P
Title: Re: Jumping/Parkour
Post by: aetios on April 28, 2016, 06:40:32 AM
I was thinking you could maybe make this a kind of 2d Mirror's edge :D
Title: Re: Jumping/Parkour
Post by: Unicorn on April 28, 2016, 06:52:50 AM
If its anything like the google images for those terms, probably not. (yet) For now, probably just a game with squares that do things. Then, sprites, then select thing like sliding and ziplining and things *.*
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on April 28, 2016, 06:56:49 AM
Sqùares that can behave differently, such as making you dash horizontally, up, down, warp elsewhere on the screen, etc, would be a nice addition.
Title: Re: Jumping/Parkour [TI 84+ CE] [C]
Post by: c4ooo on April 30, 2016, 08:32:23 PM
What sort of engine do you use? I know that V3 of mateo's C libraries contains a tilemaper, and ime also working on one. (Albeit mine is definitely not going to be as fast as Mateo's :P )
Title: Re: Jumping/Parkour
Post by: Unicorn on April 30, 2016, 09:20:01 PM
So far I haven't implemented a maping engine (if that what you mean) and I'm thinking about doing that soon.
Title: Re: Jumping/Parkour [TI 84+ CE] [C]
Post by: c4ooo on April 30, 2016, 11:33:14 PM
A tilemapper is a type of game engine were the world is divided into square "tiles" laid on a grid. Most platformer games use this method.
For excample, in mario, the world is made from different tiles like Brick, stone, air, powerup block, ect:
(http://www.tamashebi.com.ge/games/images/super-mario-crossover-2-1.png)
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on May 01, 2016, 07:31:01 AM
What @c4ooo said, and for platformer games it's generally the best solution for collision detection and world manipulation. Of course if all you display are plain color platforms that are flat rectangles then you might not need tilemapping, but it's generally recommended.

Something you can do if you have 1 platform per column is just single-dimensional map data, where each element is the height of the platform in each column. Then pits are basically the platform being so high/low that it's off the screen and not displayed at all. And you stop falling if your position at a specific column is just one block higher than the platform.
Title: Re: Jumping/Parkour
Post by: Unicorn on May 01, 2016, 07:47:00 AM
I know what tilemapping is, but I havent been able to use it yet. The tilemaps don't desifnate how the character moves, correct?
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on May 01, 2016, 07:56:36 AM
Nope they don't. At least in most cases, that is. Moving characters are separate and often refered to as sprites.

It would be worth it to learn tilemapping, though, when you get a chance. You could start with an easy language like TI-BASIC with homescreen numbers displayed from a list. Feel free to make a separate topic if you need help on tilemapping, though.
Title: Re: Jumping/Parkour [TI 84+ CE] [C]
Post by: MateoConLechuga on May 01, 2016, 04:31:32 PM
It's a good thing the C libraries have a powerful tile mapping engine that is pretty much customizable in every way. You can easily get tiles, set tiles, draw transparent and replacing tilemaps, and much more. Of course, no one has yet to use these features. ;)
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on May 01, 2016, 05:37:38 PM
Mateo do those libs work in 1, 2, 4 and 8 bits mode too? And what tile sizes are allowed?
Title: Re: Jumping/Parkour
Post by: Unicorn on May 03, 2016, 07:14:15 AM
Progress on this is halted, but I'm working on a small side-project, wich I may drop screenies about in irc.

Question, @MateoConLechuga Could I use the tilemapping engine for floodit, you think?
Title: Re: Jumping/Parkour [TI 84+ CE] [C]
Post by: MateoConLechuga on May 03, 2016, 07:23:48 AM
I wouldn't recommend it; since that means each square would be a sprite, which would use up memory. It's a lot easier to just draw rectangles :)
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on May 03, 2016, 07:35:04 AM
Yeah I agree with Mateo. Sprites/tilemaps are mainly suitable if your game uses detailed graphics or if it's the smallest way to draw your graphics in file size.
Title: Re: Jumping/Parkour [TI 84+ CE] [C]
Post by: MateoConLechuga on May 03, 2016, 07:41:49 AM
Luckily in C you can have 1D arrays (a lot like lists in basic), 2D arrays, (again, like matrices in basic), and as many XD arrays you can wrap your head around. A good 4D array is just something fun to play around with too :P Anyway, I would recommend just using a 2D array that can be created dynamically, that way you can have any board size, then just implement different functions; one to draw the board, another function to initialize the board, another to flood the board with a given color, and so on. Sorry, this topic got off track, but hopefully that helps :)

Quote from: DJ Omnimaga on May 01, 2016, 05:37:38 PM
Mateo do those libs work in 1, 2, 4 and 8 bits mode too? And what tile sizes are allowed?
Whoops, almost missed this. There's really no point to supporting anything other than 8bpp, and any graphics program that does otherwise is going to be slower than if it just used 8bpp in the first place. Lower bpp modes are mainly just for more memory if it is required. As for the allowed tile sizes, they can be powers of 2; width and height do not have to be the same however. This is just mainly again for speed reasons.
Title: Re: Jumping/Parkour
Post by: Unicorn on May 04, 2016, 06:55:59 AM
Thanks for the tips, Mateo! I see now, I had forgotten about sprites for the tilemapper... Oh, and are there any tutorials/topics on how to use convopng? Just to make things easier before I ask to mny questions ;)
Title: Re: Jumping/Parkour
Post by: Dream of Omnimaga on May 04, 2016, 04:39:30 PM
Mateo oh I thought that 1 2 and 4 bpp modes were faster due to using a smaller part of the screen.
Title: Re: Jumping/Parkour [TI 84+ CE] [C]
Post by: MateoConLechuga on May 04, 2016, 05:57:45 PM
Sure; the amount of wait states added because of a higher bpp mode is noticeable, but it simply is a lot faster to draw directly to the screen rather than shifting bits in order to display in the correct location. Anything graphics intensive should be in 8bpp mode, unless someone is using tricks to double pixels or something (Which isn't applicable in this case) :P

Quote from: Unicorn on May 04, 2016, 06:55:59 AM
Thanks for the tips, Mateo! I see now, I had forgotten about sprites for the tilemapper... Oh, and are there any tutorials/topics on how to use convopng? Just to make things easier before I ask to mny questions ;)

The release page has everything you need:
https://github.com/MateoConLechuga/ConvPNG/releases

Just put the convpng.ini file in the same directory as your images, open a command window in the same directory (usually this is src/gfx), and then type 'convpng'. Then all the graphics are included automatically.