User talk:TPAINROXX/WiiMoveIt
< User talk:TPAINROXX
Jump to navigation
Jump to search
This is an old revision of this page, as edited by TPAINROXX (talk | contribs) at 00:29, 12 July 2009. It may differ significantly from the current revision. |
![]() |
To be updated after game release... |
WiiMoveIt
Game Suggestions
Hi TPAINROXX, I don't want to be rude, but you must work a little on your graphics for WiiMoveIt, it looks like something you did with powerpoint. (p.s. I like the idea of the game, I enjoy Smooth Moves). --Elisherer 09:32, 19 June 2009 (UTC)
- Noted. I made some earlier today before reading your suggestion, so give me some feedback.--TPAINROXX/BKW 00:59, 20 June 2009 (UTC)
Help
...
Source Code
Code as of 7-11-09.
Recoded. The only problem is the code dump I get when trying to use exit_menu(), but nothing major. I know there's some weird stuff going on, but I just wanted to update for current progress. Also some tests/debugging are included, but won't be in demo/release.
main.cpp
/***********************************************/
/* WiiMoveIt - By Brandon Whitmire */
/* Powered Using GRRLIB 4.0.0 */
/***********************************************/
#include "games.hpp"
#ifndef __VER__
#define __VER__ "1.0 DEMO"
#endif
int main()
{
WiiLightOn();
GRRLIB_Init();
WPAD_Init();
GRRLIB_texImg tex_font1 = GRRLIB_LoadTexture(font1);
GRRLIB_InitTileSet(&tex_font1, 32, 32, 32);
GRRLIB_Printf(300, 30, tex_font1, LIME, 2, "LOADING...");
GRRLIB_Render();
WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(0, 640, 480);
time(&start_time);
while(1) //This displays the version and other version data.
{
clrscr();
GRRLIB_Printf(15, 30, tex_font1, AQUA, 1, "VERSION v%s", __VER__);
GRRLIB_Printf(15, 180, tex_font1, AQUA, 1, "DATE: %s", __DATE__);
GRRLIB_Printf(15, 330, tex_font1, AQUA, 1, "TIME: %s", __TIME__);
GRRLIB_Printf(380, 10, tex_font1, LIME, 2, "WIIMOVEIT");
GRRLIB_Render();
time(&cur_time);
if ( (cur_time - start_time) > 5 )
{break;}
WPAD_ScanPads();
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS)
{break;}
}
free(tex_font1.data);
intro();
exit_menu();
GRRLIB_InitTileSet(&tex_font1, 32, 32, 32);
time(&start_time);
while(1)
{
GRRLIB_FillScreen(BLACK);
GRRLIB_Printf(15, 30, tex_font1, AQUA, 1, "YOU CANCELLED!");
GRRLIB_Render();
time(&cur_time);
if ( (cur_time - start_time) > 5 )
{break;}
WPAD_ScanPads();
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS)
{break;}
}
free(tex_font1.data);
GRRLIB_Exit();
WiiLightOff();
return 0;
}
games.hpp
//---------------------------------------------------------
// games.cpp - Includes basic game engine/thing.
//---------------------------------------------------------
/*********************************************************/
//---------------------------------------------------------
// GRRLIB - So Important it has its own spot....
//---------------------------------------------------------
#include "GRRLIB/GRRLIB/GRRLIB.h" //Version packed with GRRLIB 4.0.0
//---------------------------------------------------------
// Regular Headers and Such
//---------------------------------------------------------
#include <cstdlib>
#include <time.h> //For time comparison.
#include <unistd.h> //For usleep();
#include <wiiuse/wpad.h>
#include <iostream> //May not be used; for basic output (originally).
using namespace std;
//=========================================================
// Start All File Inclusion
//=========================================================
#include "fonts/font1.h"
#include "fonts/font2.h"
#include "fonts/font3.h"
//---------------------------------------------------------
// Credits/Intro
//---------------------------------------------------------
#include "credits/BKGD.h"
#include "credits/GRRLIB.h"
#include "credits/Wilber.h"
#include "credits/BKW2.h"
#include "credits/Devkitlogo.h"
//---------------------------------------------------------
// Menu
//---------------------------------------------------------
#include "Menu/Pointer.h"
#include "Menu/WiiMoveIt.h"
#include "Menu/Exit.h"
#include "Menu/Buttons/BButton.h"
#include "Menu/Buttons/WButton.h"
#include "Menu/Buttons/Start.h"
#include "Menu/Buttons/Options.h"
#include "Menu/Buttons/Exit.h"
#include "Menu/Buttons/Button.h"
#include "Menu/Highlight.h"
#include "Menu/Highlight2.h"
//---------------------------------------------------------
// Options
//---------------------------------------------------------
/***
*
*
*
*TO BE CODED LATER
*
*
*
***/
//---------------------------------------------------------
// START GAME FILE INCLUSION BELOW
//---------------------------------------------------------
//For All Games
#include "games/All/Game_Lose.h"
#include "games/All/Game_Win.h"
#include "games/All/Game_Over.h"
//Game 1 - Tunnel
#include "games/Game 1 - Tunnel/game1_play.h"
#include "games/Game 1 - Tunnel/game1_start.h"
#include "games/Game 1 - Tunnel/thing.h"
//Game 2 - Target
#include "games/Game 2 - Target/bkgd2.h"
#include "games/Game 2 - Target/target.h"
#include "games/Game 2 - Target/crosshair.h"
//Game 3 - Search Light
//Game 4 - SpaceTravel
#include "games/Game 4 - SpaceTravel/Space4.h"
#include "games/Game 4 - SpaceTravel/Spaceship.h"
//Game 5 - The Square
//Game 6 - Fix TV
//=========================================================
//
// END OF FILE INCLUSION
//
//=========================================================
// Important Variables and Functions
//=========================================================
//Easy color codes from Crayon...
#define BLACK 0x000000FF
#define MAROON 0x800000FF
#define GREEN 0x008000FF
#define OLIVE 0x808000FF
#define NAVY 0x000080FF
#define PURPLE 0x800080FF
#define TEAL 0x008080FF
#define GRAY 0x808080FF
#define SILVER 0xC0C0C0FF
#define RED 0xFF0000FF
#define LIME 0x00FF00FF
#define YELLOW 0xFFFF00FF
#define BLUE 0x0000FFFF
#define FUCHSIA 0xFF00FFFF
#define AQUA 0x00FFFFFF
#define WHITE 0xFFFFFFFF
Mtx GXmodelView2D; //Needed for GRRLIB
void clrscr() //"Clears Screen"...
{GRRLIB_FillScreen(BLACK);}
//Wiimote 1
ir_t ir1; //IR Movement
orient_t or1; //Orientation Movement
time_t start_time, cur_time; //Time delays/comparisons.
//Wii Light - Thanks to Crayon... again...
static vu32 *_wiilight_reg = (u32*)0xCD0000C0;
void WiiLightOff()
{
*_wiilight_reg &= ~0x20;
}
void WiiLightOn()
{
*_wiilight_reg |= 0x20;
}
//---------------------------------------------------------
// Simple IR Comparison Function; Faster to Code
//---------------------------------------------------------
bool IRposition (int IRx1, int IRy1, int IRx2, int IRy2, ir_t IR_T)
/* Min X Min Y Max X Max Y IR Struct (i.e. ir1)
Return true if a point lies within specified coodinates based off the IR.*/
{return ((IRx1 <= IR_T.x) && (IRx2 >= IR_T.x) && (IRy1 <= IR_T.y) && (IRy2 >= IR_T.y));}
//---------------------------------------------------------
// Exit Function - GUI Version
//---------------------------------------------------------
void exit_menu()
{
GRRLIB_texImg tex_Pointer = GRRLIB_LoadTexture(Pointer);
GRRLIB_texImg tex_Exit = GRRLIB_LoadTexture(Exit);
GRRLIB_texImg tex_Highlight = GRRLIB_LoadTexture(Highlight);
GRRLIB_texImg tex_Highlight2 = GRRLIB_LoadTexture(Highlight2);
while(1)
{
GRRLIB_FillScreen(SILVER);
GRRLIB_DrawImg(0, 0, tex_Exit, 0, 1, 1, SILVER);
WPAD_IR(WPAD_CHAN_0, &ir1);
WPAD_Orientation(WPAD_CHAN_0, &or1);
GRRLIB_DrawImg(ir1.x, ir1.y, tex_Pointer, or1.roll, ir1.z, ir1.z, SILVER);
WPAD_ScanPads();
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_HOME)// Cancel
{break;}
else if ( IRposition (476, 61, 625, 210, ir1) ) //Cancel
{
GRRLIB_DrawImg(476, 61, tex_Highlight, 0, 1, 1, SILVER);
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_A)
{break;}
}
else if ( IRposition (16, 61, 165, 210, ir1) ) //To Wii Menu.
{
GRRLIB_DrawImg(16, 61, tex_Highlight, 0, 1, 1, SILVER);
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_A)
{SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);}
}
else if ( IRposition (221, 61, 420, 260, ir1) ) //To Loader.
{
GRRLIB_DrawImg(221, 61, tex_Highlight2, 0, 1, 1, SILVER); //Box is slightly bigger.
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_A)
{exit(0);}
}
else if ( IRposition (96, 271, 245, 420, ir1) ) //Turn off Wii.
{
GRRLIB_DrawImg(96, 271, tex_Highlight, 0, 1, 1, SILVER);
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_A)
{SYS_ResetSystem(SYS_POWEROFF, 0, 0);}
}
else if ( IRposition (386, 271, 535, 420, ir1) ) //Reset Wii.
{
GRRLIB_DrawImg(386, 271, tex_Highlight, 0, 1, 1, SILVER);
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_A)
{SYS_ResetSystem(SYS_RESTART, 0, 0);}
}
GRRLIB_Render();
}
free(tex_Exit.data);
free(tex_Pointer.data);
free(tex_Highlight.data);
}
//---------------------------------------------------------
// Intro
//---------------------------------------------------------
void END() //Test.
{
GRRLIB_texImg tex_font2 = GRRLIB_LoadTexture(font2);
GRRLIB_InitTileSet(&tex_font2, 16, 16, 32);
time(&start_time);
while(1)
{
clrscr();
GRRLIB_Printf(25, 430, tex_font2, BLUE, 1.75, "END? - TO BE CONTINUED...");
GRRLIB_Render();
time(&cur_time);
if ((cur_time - start_time) >= 3)
{break;}
}
free(tex_font2.data);
}
void intro()
{
GRRLIB_texImg tex_BKGD = GRRLIB_LoadTexture(BKGD);
GRRLIB_texImg tex_GRRLIB = GRRLIB_LoadTexture(GRRLIB);
GRRLIB_texImg tex_Wilber = GRRLIB_LoadTexture(Wilber);
GRRLIB_texImg tex_BKW2 = GRRLIB_LoadTexture(BKW2);
GRRLIB_texImg tex_Devkitlogo = GRRLIB_LoadTexture(Devkitlogo);
struct _intro_data
{
int x, y; //Positions
int deg; //Degrees
float sx, sy; //Scaling
} dINTRO, dGRRLIB, dGIMP, dBKW2, dDEVKIT; //d prefix added because of errors relating to texture loading.
dINTRO.sx = 0, dINTRO.sy = 0;
while(1)
{
GRRLIB_FillScreen(SILVER);
GRRLIB_DrawImg(0, 0, tex_BKGD, 0, dINTRO.sx, dINTRO.sy, SILVER);
GRRLIB_Render();
if (dINTRO.sx >= 1) //Just to make sure...
{break;}
WPAD_ScanPads();
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS) //For debugging; in case it never breaks.
{break;}
dINTRO.sx += .01;
dINTRO.sy += .01;
}
dGRRLIB.x = (0 - tex_GRRLIB.w);
dGRRLIB.y = (0 - tex_GRRLIB.h);
dGRRLIB.deg = 0;
dBKW2.x = (0 - tex_BKW2.w);
dBKW2.y = ((tex_BKW2.h / 2) + 240); //240 is 1/2 of 480; the screen's height. This should center the image.
dBKW2.sx = 0, dBKW2.sy = 0;
bool BKW_switch = true;
dGIMP.x = 0;
dGIMP.y = 0;
unsigned int counter = 1;
dDEVKIT.deg = 0;
time(&start_time);
while(1)
{
GRRLIB_FillScreen(SILVER);
GRRLIB_DrawImg(0, 0, tex_BKGD, 0, 1, 1, SILVER);
GRRLIB_DrawImg( 120, 350, tex_Devkitlogo, (dDEVKIT.deg += 1), 1, 1, SILVER);
GRRLIB_DrawImg(dGRRLIB.x, dGRRLIB.y, tex_GRRLIB, dGRRLIB.deg, 1, 1, SILVER);
GRRLIB_DrawImg(0, 0, tex_BKW2, 0, dBKW2.sx, dBKW2.sy, SILVER);
if (BKW_switch)
{
dBKW2.sx += .05;
dBKW2.sy += .05;
if (dBKW2.sx >= .75)
{BKW_switch = false;}
}
else
{
dBKW2.sx -= .05;
dBKW2.sy -= .05;
if (dBKW2.sx <= 0)
{BKW_switch = true;}
}
GRRLIB_DrawImg(dGIMP.x, dGIMP.y, tex_Wilber, 0, 1, 1, SILVER);
if (counter == 1)
{
dGIMP.x += 5;
if ( (dGIMP.x % 30) == 0)
{counter++;}
}
else if (counter == 2)
{
dGIMP.y += 5;
if ( (dGIMP.y % 30) == 0)
{counter--;}
}
GRRLIB_Render();
dGRRLIB.x += 3;
dGRRLIB.y += 2;
dGRRLIB.deg++;
time(&cur_time);
if ( (cur_time - start_time) >= 10 )
{break;}
WPAD_ScanPads();
if (WPAD_ButtonsHeld(0) && WPAD_BUTTON_PLUS)
{break;}
}
free(tex_BKGD.data);
free(tex_GRRLIB.data);
free(tex_Wilber.data);
free(tex_BKW2.data);
free(tex_Devkitlogo.data);
END(); //A test. Should be removed if it's here.
}
New source code. -TPAINROXX/BKW 22:29, 11 July 2009 (UTC)