page_t screen, screen2;\r
map_t map;\r
map_view_t mv, mv2;\r
- map_view_t *draw, *spri, *tmp;\r
+ map_view_t *bg, *spri, *tmp;\r
byte *ptr;\r
\r
setkb(1);\r
/* create the map */\r
- map = allocMap(MAPX,MAPY); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly\r
+ map = allocMap(MAPX,MAPY); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be bgn properly\r
initMap(&map);\r
mv.map = ↦
mv2.map = ↦\r
\r
- /* draw the tiles */\r
+ /* bg the tiles */\r
ptr = map.data;
ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite\r
modexEnter();
//modexShowPage(mv.page);\r
\r
/* set up paging */\r
- draw = &mv;\r
+ bg = &mv;\r
spri = &mv2;\r
//TODO: LOAD map data and position the map in the middle of the screen if smaller then screen
- mapGoTo(draw, 0, 0);
+ mapGoTo(bg, 0, 0);
mapGoTo(spri, 0, 0);\r
//TODO: put player in starting position of spot\r
//default player position on the viewable map
- player.tx = draw->tx + 10;
- player.ty = draw->ty + 8;
+ player.tx = bg->tx + 10;
+ player.ty = bg->ty + 8;
player.x = player.tx*TILEWH;
player.y = player.ty*TILEWH;
modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
- modexCopyPageRegion(spri->page, draw->page, player.x-4, player.y-TILEWH, player.x-4, player.y-TILEWH, 24, 34);
+ modexCopyPageRegion(bg->page, spri->page, player.x-4, player.y-TILEWH-2, player.x-4, player.y-TILEWH-2, 24, 34);
modexShowPage(spri->page);\r
while(!keyp(1))
{\r
//TODO: render the player properly with animation and sprite sheet
if(keyp(77))
{
- modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp);
- if(draw->tx >= 0 && draw->tx+20 < MAPX && player.tx == draw->tx + 10)
+ //modexCopyPageRegion(bg->page, spri->page, player.x-4, player.y-TILEWH-2, player.x-4, player.y-TILEWH-2, 24, 34);
+ //modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp);
+ if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10)
{
for(q=0; q<(TILEWH/SPEED); q++)
{
- animatePlayer(spri, draw, 1, 1, player.x, player.y, q, &ptmp);
- mapScrollRight(draw, SPEED);
+ animatePlayer(spri, bg, 1, 1, player.x, player.y, q, &ptmp);
+ mapScrollRight(bg, SPEED);
+ mapScrollRight(spri, SPEED);
modexShowPage(spri->page);
}
player.tx++;
for(q=0; q<(TILEWH/SPEED); q++)
{
player.x+=SPEED;
- animatePlayer(spri, draw, 1, 0, player.x, player.y, q, &ptmp);
+ animatePlayer(spri, bg, 1, 0, player.x, player.y, q, &ptmp);
modexShowPage(spri->page);
}
player.tx++;
\r
if(keyp(75))
{
- modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp);
- if(draw->tx > 0 && draw->tx+20 <= MAPX && player.tx == draw->tx + 10)
+ //modexCopyPageRegion(bg->page, spri->page, player.x-4, player.y-TILEWH-2, player.x-4, player.y-TILEWH-2, 24, 34);
+ //modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp);
+ if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10)
{
for(q=0; q<(TILEWH/SPEED); q++)
{
- animatePlayer(spri, draw, 3, 1, player.x, player.y, q, &ptmp);
- mapScrollLeft(draw, SPEED);
+ animatePlayer(spri, bg, 3, 1, player.x, player.y, q, &ptmp);
+ mapScrollLeft(bg, SPEED);
+ mapScrollLeft(spri, SPEED);
modexShowPage(spri->page);
}
player.tx--;\r
for(q=0; q<(TILEWH/SPEED); q++)
{
player.x-=SPEED;
- animatePlayer(spri, draw, 3, 0, player.x, player.y, q, &ptmp);
+ animatePlayer(spri, bg, 3, 0, player.x, player.y, q, &ptmp);
modexShowPage(spri->page);
}
player.tx--;
\r
if(keyp(80))
{
- modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
- if(draw->ty >= 0 && draw->ty+15 < MAPY && player.ty == draw->ty + 8)
+ //modexCopyPageRegion(bg->page, spri->page, player.x-4, player.y-TILEWH-2, player.x-4, player.y-TILEWH-2, 24, 34);
+ //modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp);
+ if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8)
{\r
for(q=0; q<(TILEWH/SPEED); q++)
{
- animatePlayer(spri, draw, 2, 1, player.x, player.y, q, &ptmp);
- mapScrollDown(draw, SPEED);
+ animatePlayer(spri, bg, 2, 1, player.x, player.y, q, &ptmp);
+ mapScrollDown(bg, SPEED);
+ mapScrollDown(spri, SPEED);
modexShowPage(spri->page);
}
player.ty++;
for(q=0; q<(TILEWH/SPEED); q++)
{
player.y+=SPEED;
- animatePlayer(spri, draw, 2, 0, player.x, player.y, q, &ptmp);
+ animatePlayer(spri, bg, 2, 0, player.x, player.y, q, &ptmp);
modexShowPage(spri->page);
}
player.ty++;
\r
if(keyp(72))
{
- modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp);
- if(draw->ty > 0 && draw->ty+15 <= MAPY && player.ty == draw->ty + 8)
+ //modexCopyPageRegion(bg->page, spri->page, player.x-4, player.y-TILEWH-2, player.x-4, player.y-TILEWH-2, 24, 34);
+ //modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp);
+ if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8)
{\r
for(q=0; q<(TILEWH/SPEED); q++)
{
- animatePlayer(spri, draw, 0, 1, player.x, player.y, q, &ptmp);
- mapScrollUp(draw, SPEED);
+ animatePlayer(spri, bg, 0, 1, player.x, player.y, q, &ptmp);
+ mapScrollUp(bg, SPEED);
mapScrollUp(spri, SPEED);
modexShowPage(spri->page);
}
for(q=0; q<(TILEWH/SPEED); q++)
{
player.y-=SPEED;
- animatePlayer(spri, draw, 0, 0, player.x, player.y, q, &ptmp);
+ animatePlayer(spri, bg, 0, 0, player.x, player.y, q, &ptmp);
modexShowPage(spri->page);
}
player.ty--;
modexLeave();\r
setkb(0);
printf("Project 16 scroll.exe\n");
- printf("tx: %d\n", draw->tx);
- printf("ty: %d\n", draw->ty);
+ printf("tx: %d\n", bg->tx);
+ printf("ty: %d\n", bg->ty);
printf("player.x: %d\n", player.x);
printf("player.y: %d\n", player.y);
printf("player.tx: %d\n", player.tx);
\r
void\r
mapScrollRight(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
+ word x, y; /* coordinate for bging */\r
\r
/* increment the pixel position and update the page */\r
mv->page->dx += offset;\r
mv->page->dx = mv->map->tiles->tileWidth;\r
\r
\r
- /* draw the next column */\r
+ /* bg the next column */\r
x= SCREEN_WIDTH + mv->map->tiles->tileWidth;\r
mapDrawCol(mv, mv->tx + 20 , mv->ty-1, x);\r
}\r
\r
void\r
mapScrollLeft(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
+ word x, y; /* coordinate for bging */\r
\r
/* increment the pixel position and update the page */\r
mv->page->dx -= offset;\r
mv->page->data -= 4;\r
mv->page->dx = mv->map->tiles->tileWidth;\r
\r
- /* draw the next column */\r
+ /* bg the next column */\r
mapDrawCol(mv, mv->tx-1, mv->ty-1, 0);\r
}\r
}\r
\r
void\r
mapScrollUp(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
+ word x, y; /* coordinate for bging */\r
\r
/* increment the pixel position and update the page */\r
mv->page->dy -= offset;\r
mv->page->dy = mv->map->tiles->tileHeight;\r
\r
\r
- /* draw the next row */\r
+ /* bg the next row */\r
y= 0;\r
mapDrawRow(mv, mv->tx-1 , mv->ty-1, y);\r
}\r
\r
void\r
mapScrollDown(map_view_t *mv, byte offset) {\r
- word x, y; /* coordinate for drawing */\r
+ word x, y; /* coordinate for bging */\r
\r
/* increment the pixel position and update the page */\r
mv->page->dy += offset;\r
mv->page->dy = mv->map->tiles->tileHeight;\r
\r
\r
- /* draw the next row */\r
+ /* bg the next row */\r
y= SCREEN_HEIGHT + mv->map->tiles->tileHeight;\r
mapDrawRow(mv, mv->tx-1 , mv->ty+15, y);\r
}\r
mv->dxThresh = mv->map->tiles->tileWidth * 2;\r
mv->dyThresh = mv->map->tiles->tileHeight * 2;\r
\r
- /* draw the tiles */\r
+ /* bg the tiles */\r
modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0);\r
py=0;\r
i=mv->ty * mv->map->width + mv->tx;\r
break;
case 1:
// right
- if(ls<1) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ if(ls<1) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); }
- if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 48, 32, 24, 32, bmp); }
- if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 0, 32, 24, 32, bmp); }
- if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);
+ if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x+qq-4, y-TILEWH, x+qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); }
break;
case 2:
//down
- if(ls<1) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ if(ls<1) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH-2, x-4, y+qq-TILEWH-2, 24, 34);
modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); }
- if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH-2, x-4, y+qq-TILEWH-2, 24, 34);
modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 48, 64, 24, 32, bmp); }
- if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH-2, x-4, y+qq-TILEWH-2, 24, 34);
modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 0, 64, 24, 32, bmp); }
- if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH, x-4, y+qq-TILEWH, 24, 34);
+ if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x-4, y+qq-TILEWH-2, x-4, y+qq-TILEWH-2, 24, 34);
modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); }
break;
case 3:
//left
- if(ls<1) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ if(ls<1) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); }
- if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ if(4>ls && ls>=1) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 48, 96, 24, 32, bmp); }
- if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ if(7>ls && ls>=4) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 0, 96, 24, 32, bmp); }
- if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);
+ if(ls>=7) { modexCopyPageRegion(mv->page, src->page, x-qq-4, y-TILEWH, x-qq-4, y-TILEWH, 24, 34);// modexWaitBorder();
modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); }
break;
}