Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
For the first keyword, I am decided to do a math game with snowflakes. It's called SnowMath. This is being made on the TI-84+CE in C. Basically, my end goal is to have addition, subtraction, multiplication, and division. All integer based, so there WILL NOT be any decimals.


Done:

  • Snow
  • Random Generator


Not Done:

  • Menu
  • Highscores
  • The actual Math Game
An update:

I added a menu and I'm close to adding the actual game. I'm going to guess a maximum of 12KB in size, but I don't know yet. I also added wind, that can change directions and speeds, but I haven't gotten to that yet.



Edit:
I added in wind in both directions and multiple speeds, and I added in blizzard which changes downward speed every 4 and adds more snow.

Any updates so far? This looks like an interesting math game, although I wonder what you actually need to do?
So I added snowflakes and fixed a lot of bugs except for a few.

As you can see I have problems with snow when I increase blizzard. Also for some reason, the snowflakes move faster in the y direction.
Here's my code if you have any suggestions.

draw.c

Code:
/* 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>

//libraries
#include "graphx.h"
#include <fileioc.h>
#include <keypadc.h>

//includes
#include "gfx/snowflake_gfx.h"
#include "appvar.h"
#include "draw.h"
#include "game.h"
#include "main.h"

//variables
uint8_t snowCount, flakeCount, cursory = 100;
int count = 0;
struct snow snowMain[200], snowGame[200], snowflakeXY[20];

void draw_Snow(int snowX, int flakex, uint8_t file) {
    unsigned int i = 0;

    if (count%(21 - (blizzard * ((bool)blizzard)) - (2 * (!blizzard)))) {
        if (!(count%2) || (!(count%(10 - abs(windVelocity))) && wind)) {
            if (file == MAIN) {
                i = 0;
                while (i <= snowCount) {
                    snowMain[i].y += (blizzard / 5) + 1;
                    if (wind) {
                        snowMain[i].x += windVelocity;
                        if (snowMain[i].x < 0)
                            snowMain[i].x = 320;
                        else if (snowMain[i].x > 320)
                            snowMain[i].x = 0;
                    }
                    if (snowMain[i].y > 240) {
                        snowMain[i].x = 0;
                        snowMain[i].y = 0;
                        if (i != snowCount)
                            snowMain[i] = snowMain[snowCount];
                        snowCount--;
                    }
                    i++;
                }
                i = 0;
            }else {
                i = 0;
                while (i <= snowCount) {
                    snowGame[i].y += (blizzard / 5) + 1;
                    if (wind) {
                        snowGame[i].x += windVelocity;
                        if (snowGame[i].x < 0)
                            snowGame[i].x = 320;
                        else if (snowGame[i].x > 320)
                            snowGame[i].x = 0;
                    }
                    if (snowGame[i].y > 240) {
                        snowGame[i].x = 0;
                        snowGame[i].y = 0;
                        if (i != snowCount)
                            snowGame[i] = snowGame[snowCount];
                        snowCount--;
                    }
                    i++;
                }
                i = 0;
            }
        }
    }else {
        snowCount++;
        if (file == MAIN) {
            i = 0;
            while (i <= snowCount) {
                if (i == snowCount) {
                    snowMain[i].x = snowX;
                    snowMain[i].y = 0;
                }
                snowMain[i].y += (blizzard / 5) + 1;
                if (wind) {
                    snowMain[i].x += windVelocity;
                    if (snowMain[i].x < 0)
                        snowMain[i].x = 320;
                    else if (snowMain[i].x > 320)
                        snowMain[i].x = 0;
                }
                if (snowMain[i].y > 240) {
                    snowMain[i].x = 0;
                    snowMain[i].y = 0;
                    if (i != snowCount - 1)
                        snowMain[i] = snowMain[snowCount - 1];
                    snowCount--;
                }
                i++;
            }
        }else {
            i = 0;
            while (i <= snowCount) {
                if (i == snowCount) {
                    snowGame[i].x = snowX;
                    snowGame[i].y = 0;
                }
                snowGame[i].y += (blizzard / 5) + 1;
                if (wind) {
                    snowGame[i].x += windVelocity;
                    if (snowGame[i].x < 0)
                        snowGame[i].x = 320;
                    else if (snowGame[i].x > 320)
                        snowGame[i].x = 0;
                }
                if (snowGame[i].y > 240) {
                    snowGame[i].x = 0;
                    snowGame[i].y = 0;
                    if (i != snowCount - 1)
                        snowGame[i] = snowGame[snowCount - 1];
                    snowCount--;
                }
                i++;
            }
        }
    }
    i = 0;
    if (count && count%(50 - (2 * (blizzard / 2)))) {
        if (file == MAIN) {
            while (i <= flakeCount) {
                snowflakeXY[i].y += ((int)(blizzard / 10)) + 1;
                if (wind) {
                    snowflakeXY[i].x += (windVelocity != 1)?windVelocity / 2:windVelocity;
                    if (snowflakeXY[i].x < 0)
                        snowflakeXY[i].x = 320;
                    else if (snowflakeXY[i].x > 320)
                        snowflakeXY[i].x = 0;
                }
                if (snowflakeXY[i].y >= 200 && snowflakeXY[i].y < 210) {
                    snowflakeXY[i].x = 0;
                    snowflakeXY[i].y = 0;
                    if (i != flakeCount)
                        snowflakeXY[i] = snowflakeXY[flakeCount];
                    flakeCount--;
                }
                i++;
            }
        }else {
            while (i <= flakeCount) {
                snowflakeXY[i].y += (SPEEDINC != SPEEDMAX)?SPEEDINC:SPEEDMAX;
                if (snowflakeXY[i].y + snowflake_data[1] >= SNOWLAYER) {
                    snowflakeXY[i].x = 0;
                    snowflakeXY[i].y = 0;
                    if (i != flakeCount)
                        snowflakeXY[i] = snowflakeXY[flakeCount];
                    flakeCount--;
                    missed++;
                }
                i++;
            }
        }
    }else {
        if (file == MAIN) {
            flakeCount++;
            while (i <= flakeCount) {
                if (i == flakeCount) {
                    snowflakeXY[i].x = flakex;
                    snowflakeXY[i].y = 210;
                }
                snowflakeXY[i].y += ((int)(blizzard / 10)) + 1;
                if (wind) {
                    snowflakeXY[i].x += windVelocity / 2;
                    if (snowflakeXY[i].x < 0)
                        snowflakeXY[i].x = 320;
                    else if (snowflakeXY[i].x > 320)
                        snowflakeXY[i].x = 0;
                }
                if (snowflakeXY[i].y >= 200 && snowflakeXY[i].y < 210) {
                    snowflakeXY[i].x = 0;
                    snowflakeXY[i].y = 0;
                    if (i != flakeCount)
                        snowflakeXY[i] = snowflakeXY[flakeCount - 1];
                    flakeCount--;
                }
                i++;
            }
        }else {
            flakeCount += 2;
            while (i <= flakeCount) {
                if (i == flakeCount - 1) {
                    snowflakeXY[i].x = 80 - 15;
                    snowflakeXY[i].y = 0;
                }else if (i == flakeCount) {
                    snowflakeXY[i].x = 240 - 15;
                    snowflakeXY[i].y = 0;
                }
                snowflakeXY[i].y += (SPEEDINC != SPEEDMAX)?SPEEDINC:SPEEDMAX;
                if (snowflakeXY[i].y + snowflake_data[1] >= SNOWLAYER) {
                    snowflakeXY[i].x = 0;
                    snowflakeXY[i].y = 0;
                    if (i != flakeCount)
                        snowflakeXY[i] = snowflakeXY[flakeCount - 1];
                    flakeCount--;
                    missed++;
                }
                i++;
            }
        }
    }
    i = 0;
    gfx_SetColor(0xFF);
    if (file == MAIN)
        while (i <= snowCount) {
            gfx_FillRectangle(snowMain[i].x, snowMain[i].y, 3, 3);
            i++;
        }
    else
        while (i <= snowCount) {
            gfx_FillRectangle(snowGame[i].x, snowGame[i].y, 3, 3);
            i++;
        }
    i = 0;
    while (i <= flakeCount) {
        gfx_TransparentSprite_NoClip(snowflake, snowflakeXY[i].x, snowflakeXY[i].y);
        i++;
    }
/*    if (file == MAIN) {
        gfx_SetColor(0xFF);
        gfx_FillRectangle(0, 200, 320, 40);
    }*/
    count++;
}

uint8_t draw_Menu() {
    switch (key) {
    case sk_Down:
        if (cursory == 160)
            cursory = 100;
        else
            cursory += 10;
        break;
    case sk_Up:
        if (cursory == 100)
            cursory = 160;
        else
            cursory -= 10;
        break;
    case sk_Left:
        if (cursory == 140) {
            if (level == 1)
                level = levelmax;
            else
                level--;
        }else if (cursory == 150) {
            if (!wind) {
                wind = true;
                windVelocity = -1;
            }else if (windVelocity == 1) {
                wind = false;
                windVelocity = 0;
            }else if (windVelocity == -9) {
                windVelocity = 9;
            }else
                windVelocity--;
        }else if (cursory == 160) {
            if (!blizzard)
                blizzard = 20;
            else
                blizzard--;
        }
        break;
    case sk_Right:
        if (cursory == 140) {
            if (level == levelmax)
                level = 1;
            else
                level++;
        }else if (cursory == 150) {
            if (!wind) {
                wind = true;
                windVelocity = 1;
            }else if (windVelocity == 9) {
                windVelocity = -9;
            }else if (windVelocity == -1) {
                wind = false;
                windVelocity = 0;
            }else
                windVelocity++;
        }else if (cursory == 160) {
            if (blizzard == 20)
                blizzard = 0;
            else
                blizzard++;
        }
        break;
    case sk_2nd:
        return (cursory%100) / 10;
    }
    gfx_SetTextScale(3, 2);
    gfx_PrintStringXY("Snow Math", 160 - (gfx_GetStringWidth("Snow Math")/2), 50);
    gfx_SetTextScale(1, 1);
    gfx_PrintStringXY("Addition", 130, 100);
    gfx_PrintStringXY("Subtraction", 130, 110);
    gfx_PrintStringXY("Multiplication", 130, 120);
    gfx_PrintStringXY("Division", 130, 130);
    gfx_PrintStringXY("Level:", 130, 140);
    gfx_PrintStringXY("Wind:", 130, 150);
    gfx_PrintStringXY("Blizzard:", 130, 160);
    gfx_SetTextXY(135 + gfx_GetStringWidth("Level:"), 140);
    gfx_PrintUInt(level, 1);
    gfx_SetTextXY(135 + gfx_GetStringWidth("Wind:"), 150);
    gfx_PrintInt(windVelocity, 2);
    gfx_SetTextXY(135 + gfx_GetStringWidth("Blizzard:"), 160);
    gfx_PrintUInt(blizzard, 2);
    gfx_PrintStringXY(">", 120, cursory);
    gfx_SwapDraw();
    return 255;
}


draw.h

Code:
#ifndef DRAW_H
#define DRAW_H

#define MAIN    0
#define GAME    1

void draw_Snow(int snowX, int flakex, uint8_t file);
uint8_t draw_Menu();

extern uint8_t snowCount, flakeCount;
extern int count;
extern struct snow {
    int x;
    int y;
}snowMain[200], snowGame[200], snowflakeXY[20];


#endif // DRAW_H
I don't know if this is possible, but maybe you could start the snowflakes above the screen. That way, they would fall onto the screen from above instead of appearing out of thin air at the top.
Kydapoot wrote:
I don't know if this is possible, but maybe you could start the snowflakes above the screen. That way, they would fall onto the screen from above instead of appearing out of thin air at the top.

But then this happens, (starting at the bottom and above is the same because of the way negatives are handled):

Took out the snow at the bottom so you could see.
If I change my code, I will change it in the post above fyi.
If you are talking about the flickering, I believe that is a CEmu bug, have you tested it on hardware?

Other than that, looks nice!
Unicorn wrote:
If you are talking about the flickering, I believe that is a CEmu bug, have you tested it on hardware?

Other than that, looks nice!

Or maybe it could be that he is using gfx_TransparentSprite_NoClip when he is trying to clip things Wink Fix that and everything works fine.
Fixed the snow!!! Now I will fix the snowflakes.


Edit:
I FIXED IT!!! YAY!!!
Well, my mistake. I did not pay attention to what UTC time was. Now I know. I don't know if I will have anything this week, so I may have to just drop out due to my busy holiday break.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement