shuffle code around
This commit is contained in:
parent
5ce88d42cf
commit
a30af87485
|
@ -4,8 +4,8 @@
|
|||
#include <dos.h>
|
||||
|
||||
#include "bmpload.h"
|
||||
#include "pc_stuff.h"
|
||||
#include "vga.h"
|
||||
#include "system/pc_stuff.h"
|
||||
#include "system/vga.h"
|
||||
|
||||
int readBMPHeader(FILE *fh, struct BMPImage *info) {
|
||||
int sizeOfHeader;
|
||||
|
|
44
game.c
44
game.c
|
@ -2,10 +2,10 @@
|
|||
#include <math.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include "vga.h"
|
||||
#include "keyboard.h"
|
||||
#include "mouse_io.h"
|
||||
#include "pc_stuff.h"
|
||||
#include "system/vga.h"
|
||||
#include "system/keyboard.h"
|
||||
#include "system/mouse_io.h"
|
||||
#include "system/pc_stuff.h"
|
||||
#include "bmpload.h"
|
||||
|
||||
struct BMPImage spritesheetImage;
|
||||
|
@ -113,7 +113,6 @@ int rabbitLimits[2][2] = {
|
|||
|
||||
signed char rabbitVelocity[2] = { 0, 0 };
|
||||
|
||||
struct SpriteBounds bounds;
|
||||
struct MouseStatus mouseStatus;
|
||||
char mousePosition[2] = { 0, 0 };
|
||||
|
||||
|
@ -184,14 +183,18 @@ void handleRabbitMovement() {
|
|||
}
|
||||
}
|
||||
|
||||
#define TILE_SIZE (20)
|
||||
|
||||
struct SpriteBounds bounds;
|
||||
|
||||
void drawOnlyArena() {
|
||||
int leftTileX, rightTileX,
|
||||
topTileY, bottomTileY;
|
||||
|
||||
leftTileX = bounds.left / 20;
|
||||
rightTileX = bounds.right / 20;
|
||||
topTileY = bounds.top / 20;
|
||||
bottomTileY = bounds.bottom / 20;
|
||||
leftTileX = bounds.left / TILE_SIZE;
|
||||
rightTileX = bounds.right / TILE_SIZE;
|
||||
topTileY = bounds.top / TILE_SIZE;
|
||||
bottomTileY = bounds.bottom / TILE_SIZE;
|
||||
|
||||
renderArenaTile(leftTileX, topTileY);
|
||||
if (leftTileX != rightTileX) {
|
||||
|
@ -221,28 +224,18 @@ void drawOnlyRabbitArena() {
|
|||
#define DEG2RAD (3.14159/180)
|
||||
#define MOUSE_DISTANCE (32)
|
||||
|
||||
void calculateMouseAngle() {
|
||||
void calculateTargetAngle() {
|
||||
float distanceX, distanceY;
|
||||
float angle;
|
||||
|
||||
char buffer[20];
|
||||
|
||||
distanceX = mouseStatus.xPosition - rabbitPosition[0];
|
||||
distanceY = mouseStatus.yPosition - rabbitPosition[1];
|
||||
|
||||
angle = atan2(distanceY, distanceX) * 180 / 3.14159;
|
||||
angle = atan2(distanceY, distanceX) * 180 / 3.14159 + 90;
|
||||
if (angle < 0) angle += 360;
|
||||
|
||||
sprintf(buffer, "%f", angle);
|
||||
writeString(buffer, 0, 2);
|
||||
|
||||
sprintf(buffer, "%f", distanceX);
|
||||
writeString(buffer, 0, 3);
|
||||
|
||||
sprintf(buffer, "%d", mouseStatus.xPosition);
|
||||
writeString(buffer, 0, 4);
|
||||
|
||||
distanceX = cos(angle * DEG2RAD) * MOUSE_DISTANCE;
|
||||
distanceY = sin(angle * DEG2RAD) * MOUSE_DISTANCE;
|
||||
distanceX = sin(angle * DEG2RAD) * MOUSE_DISTANCE;
|
||||
distanceY = -cos(angle * DEG2RAD) * MOUSE_DISTANCE;
|
||||
|
||||
mousePosition[0] = rabbitPosition[0] + distanceX;
|
||||
mousePosition[1] = rabbitPosition[1] + distanceY;
|
||||
|
@ -276,7 +269,7 @@ int main(void) {
|
|||
readMouse(&mouseStatus);
|
||||
populateKeyboardKeydownState();
|
||||
handleRabbitMovement();
|
||||
calculateMouseAngle();
|
||||
calculateTargetAngle();
|
||||
|
||||
waitStartVbl();
|
||||
|
||||
|
@ -287,7 +280,6 @@ int main(void) {
|
|||
renderRabbit();
|
||||
renderMouse();
|
||||
copyDrawBufferToDisplay();
|
||||
calculateMouseAngle();
|
||||
|
||||
waitEndVbl();
|
||||
|
||||
|
|
18
makefile
18
makefile
|
@ -1,7 +1,19 @@
|
|||
obj = game.o bmpload.o mouse_io.o pc_stuff.o vga.o keyboard.o
|
||||
obj = game.o bmpload.o
|
||||
|
||||
all: system/system.lib game.exe .SYMBOLIC
|
||||
|
||||
system/system.lib: .SYMBOLIC
|
||||
cd system
|
||||
wmake
|
||||
cd ..
|
||||
|
||||
.c.o:
|
||||
wcc386 -q -bt=dos -q $<
|
||||
wcc386 -q -bt=dos $<
|
||||
|
||||
game.exe: $(obj)
|
||||
wcl386 -q -bt=dos -l=dos4g $(obj)
|
||||
wcl386 -q -bt=dos -l=dos4g $(obj) system/system.lib
|
||||
|
||||
clean: .SYMBOLIC
|
||||
rm *.o
|
||||
rm system/*.o
|
||||
rm system/*.lib
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __KEYBOARD_H__
|
||||
#define __KEYBOARD_H__ 1
|
||||
|
||||
#include "types.h"
|
||||
#include "../types.h"
|
||||
|
||||
extern unsigned char keystateBits[];
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
obj = pc_stuff.o vga.o keyboard.o mouse_io.o
|
||||
|
||||
.c.o:
|
||||
wcc386 -q -bt=dos $<
|
||||
|
||||
system.lib: $(obj)
|
||||
wlib -n system.lib $(obj:%=+%)
|
|
@ -4,7 +4,7 @@
|
|||
#include <conio.h>
|
||||
#include <dos.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "../types.h"
|
||||
|
||||
extern byte *VGA;
|
||||
|
Binary file not shown.
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "bmpload.h"
|
||||
#include "../types.h"
|
||||
#include "../bmpload.h"
|
||||
|
||||
#define VGA_DISPLAY_WIDTH (320)
|
||||
#define VGA_DISPLAY_HEIGHT (200)
|
Loading…
Reference in New Issue