Skip to content

Commit c70fbeb

Browse files
committedJul 31, 2021
update
- fixed ai hitboxes - added skins
1 parent 8cb6955 commit c70fbeb

14 files changed

+96
-7
lines changed
 

‎.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Built PSP Files
2+
*.o
3+
*.pbp
4+
*.elf
5+
*.prx

‎README.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
this is an old project made using the pspdev kit, now being updated for hopefully some time
1111

12-
## bugs
12+
## known bugs
1313
players hitbox is bigger than how the player appears
1414
if you eat too much food and players the whole map shrinks into nothingness and player is left alone in a blank world
15-
ai hitboxes are goofy
1615

1716
THE CRASHING IS FIXED! it was because the player's small was smaller than 40
1817

@@ -24,7 +23,7 @@ add viruses (green spiky circles)
2423
open a terminal in the src directory and type "make". itll make a EBOOT.pbp file for you to play
2524

2625
## putting on your psp
27-
make a folder and in that folder copy every png file other than ICON0.png into the folder
26+
make a folder and in that folder copy every png file other than ICON0.png and PIC1.png into the folder
2827
put built eboot.pbp in the folder with the copyed png files and put the folder in PSP/GAME
2928
goto games and you will see the game
3029

‎src/Agar.elf

759 Bytes
Binary file not shown.

‎src/Agar.prx

664 Bytes
Binary file not shown.

‎src/EBOOT.PBP

36.8 KB
Binary file not shown.

‎src/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ LIBS = -lpng -ljpeg -lz -lpspgu -lm -lpspvram
1717
EXTRA_TARGETS = EBOOT.PBP
1818
PSP_EBOOT_TITLE = Agario
1919
PSP_EBOOT_ICON = ICON0.PNG
20+
PSP_EBOOT_PIC1 = PIC1.PNG
2021

2122
PSPSDK=$(shell psp-config --pspsdk-path)
2223
include $(PSPSDK)/lib/build.mak

‎src/PIC1.png

36.2 KB
Loading

‎src/agarskin_cia.png

3.71 KB
Loading

‎src/agarskin_facepunch.png

7.62 KB
Loading

‎src/agarskin_sussy.png

9.9 KB
Loading

‎src/agarskin_tiktok.png

6.63 KB
Loading

‎src/main.cpp

+88-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <glib2d.h>
1414

1515

16+
//i coded this all on my own
1617
PSP_MODULE_INFO("agario", 0, 1, 0);
1718
PSP_HEAP_SIZE_KB(-256);
1819

@@ -55,16 +56,25 @@ struct AI {
5556
int color = 10;
5657
int dir = 1;
5758
int tick = 1;
59+
int skin = 0;
60+
g2dTexture* chosenSkin = g2dTexLoad("cell.png",G2D_SWIZZLE);
5861
};
5962

6063
auto main() -> int {
6164

65+
SceCtrlLatch latchData;
66+
6267
g2dTexture* bg = g2dTexLoad("grid.png",G2D_SWIZZLE);
6368
g2dTexture* title = g2dTexLoad("title.png",G2D_SWIZZLE);
6469
g2dTexture* tex = g2dTexLoad("cell.png",G2D_SWIZZLE);
6570

6671
g2dColors color[7] = {RED,ORANGE,YELLOW,GREEN,BLUE,VIOLET,ROSE};
6772

73+
char* skins[5] = {"default","agarskin_cia.png","agarskin_facepunch.png","agarskin_tiktok.png","agarskin_sussy.png"};
74+
int mySkin = 1;
75+
76+
g2dTexture* plr_skin = g2dTexLoad(skins[mySkin],G2D_SWIZZLE);
77+
6878
Food dots[250];
6979
for (int i = 0; i < 250; i++) {
7080
dots[i].foodX = rand() % 2000 - 90;
@@ -80,6 +90,10 @@ auto main() -> int {
8090
plrs[i].tick = rand() % 20 + 1;
8191
plrs[i].dir = rand() % 3 + 1;
8292
plrs[i].color = rand() % 7;
93+
plrs[i].skin = rand() % 4;
94+
if (plrs[i].skin != 0){
95+
plrs[i].chosenSkin = g2dTexLoad(skins[plrs[i].skin],G2D_SWIZZLE);
96+
}
8397
}
8498

8599
//Virus spots[10]; // unused for now
@@ -132,6 +146,15 @@ auto main() -> int {
132146
g2dSetCoordXY((plrs[loop].pX - x) / (mass / 40) + 240,(plrs[loop].pY - y) / (mass / 40) + 132);
133147
g2dAdd();
134148
g2dEnd();
149+
if(plrs[loop].skin != 0){
150+
// render ai skin!
151+
g2dSetColor(WHITE);
152+
g2dBeginRects(plrs[loop].chosenSkin);
153+
g2dSetScaleWH(plrs[loop].score / (mass / 40),plrs[loop].score / (mass / 40));
154+
g2dSetCoordXY((plrs[loop].pX - x) / (mass / 40) + 240,(plrs[loop].pY - y) / (mass / 40) + 132);
155+
g2dAdd();
156+
g2dEnd();
157+
}
135158
plrs[loop].tick++;
136159
if(plrs[loop].tick >= plrs[loop].score * 2){
137160
plrs[loop].tick = 0;
@@ -157,7 +180,7 @@ auto main() -> int {
157180

158181
// ai eats pellets
159182
for (int i2 = 0; i2 < 240; i2++) {
160-
if (collision((plrs[loop].pX - x) / (mass / 40) + 240 ,(plrs[loop].pY - y) / (mass / 40) + 132 , (dots[i2].foodX - x) / (mass / 40) + 240 , (dots[i2].foodY - y) / (mass / 40) + 132 ,plrs[loop].score / (mass / 40),plrs[loop].score / (mass / 40),4,4)) {
183+
if (collision((plrs[loop].pX - x) / (mass / 40) + 240 + plrs[loop].score ,(plrs[loop].pY - y) / (mass / 40) + 132 + plrs[loop].score , (dots[i2].foodX - x) / (mass / 40) + 240 , (dots[i2].foodY - y) / (mass / 40) + 132 ,plrs[loop].score / (mass / 40),plrs[loop].score / (mass / 40),4,4)) {
161184
plrs[loop].score+= 10 / (plrs[loop].score / 4);
162185
dots[i2].foodX = rand() % 2000 - 90;
163186
dots[i2].foodY = rand() % 2000 + 10;
@@ -166,7 +189,7 @@ auto main() -> int {
166189

167190
for (int i3 = 0; i3 < 60; i3++) {
168191
// ai eat ai
169-
if (collision((plrs[loop].pX - x) / (mass / 40) + 240 ,(plrs[loop].pY - y) / (mass / 40) + 132 , (plrs[i3].pX - x) / (mass / 40) + 240 , (plrs[i3].pY - y) / (mass / 40) + 132 ,plrs[loop].score / (mass / 40),plrs[loop].score / (mass / 40),plrs[i3].score / (mass / 40),plrs[i3].score / (mass / 40))) {
192+
if (collision((plrs[loop].pX - x) / (mass / 40) + 240 + plrs[loop].score ,(plrs[loop].pY - y) / (mass / 40) + 132 + plrs[loop].score , (plrs[i3].pX - x) / (mass / 40) + 240+ plrs[i3].score , (plrs[i3].pY - y) / (mass / 40) + 132 + plrs[i3].score ,plrs[loop].score / (mass / 40),plrs[loop].score / (mass / 40),plrs[i3].score / (mass / 40),plrs[i3].score / (mass / 40))) {
170193
if (plrs[loop].score > plrs[loop1].score + 30) {
171194
plrs[loop].score += (plrs[loop1].score / 4);
172195
plrs[i3].score = rand() % 100 + 10;
@@ -182,13 +205,13 @@ auto main() -> int {
182205
}
183206

184207
// collision detection for player
185-
if (collision(240 + (massSize / 2) ,132 + (massSize / 2) , (plrs[loop].pX - x) / (mass / 40) + 240 , (plrs[loop].pY - y) / (mass / 40) + 132 ,massSize,massSize,plrs[loop].score / (mass / 40),plrs[loop].score / (mass / 40))) {
208+
if (collision(240 + (massSize / 2) ,132 + (massSize / 2) , (plrs[loop].pX - x) / (mass / 40) + 240 + plrs[loop].score , (plrs[loop].pY - y) / (mass / 40) + 132 + plrs[loop].score ,massSize,massSize,plrs[loop].score / (mass / 40),plrs[loop].score / (mass / 40))) {
186209
if (mass > plrs[loop].score + 30) {
187210
mass += (plrs[loop].score / 4);
188211
plrs[loop].score = 10;
189212
plrs[loop].pX = rand() % 2000 - 90;
190213
plrs[loop].pY = rand() % 2000 + 10;
191-
} else if (plrs[loop].score > mass - 5) {
214+
} else if (plrs[loop].score > mass - 15) {
192215

193216
x = 0;
194217
y = 0;
@@ -224,6 +247,19 @@ auto main() -> int {
224247
dir = 4;
225248
}
226249
if (ctrlData.Buttons & PSP_CTRL_CIRCLE) {
250+
x = 0;
251+
y = 0;
252+
mass = 45;
253+
254+
// reset positions of all players
255+
for (int i4 = 0; i4 < 100; i4++) {
256+
plrs[i4].pX = rand() % 2000 - 90;
257+
plrs[i4].pY = rand() % 2000 + 10;
258+
plrs[i4].score = rand() % 100 + 10;
259+
plrs[i4].tick = rand() % 20 + 1;
260+
plrs[i4].dir = rand() % 3 + 1;
261+
plrs[i4].color = rand() % 7;
262+
}
227263
state=0;
228264
}
229265

@@ -255,6 +291,18 @@ auto main() -> int {
255291

256292
g2dAdd();
257293
g2dEnd();
294+
295+
// skin (added onto cell if skin is chosen)
296+
if(mySkin != 0){
297+
// apply the skin!
298+
g2dBeginRects(plr_skin);
299+
g2dSetColor(WHITE);
300+
g2dSetScaleWH(massSize / (mass / 40),massSize / (mass / 40));
301+
g2dSetCoordXY((480 - massSize / (mass / 40)) / 2 ,(272 - massSize / (mass / 40)) / 2);
302+
303+
g2dAdd();
304+
g2dEnd();
305+
}
258306

259307
g2dFlip(G2D_VSYNC);
260308

@@ -268,6 +316,8 @@ auto main() -> int {
268316
g2dAdd();
269317
g2dEnd();
270318

319+
sceCtrlReadLatch(&latchData);
320+
271321
sceCtrlReadBufferPositive(&ctrlData, 1);
272322
if (ctrlData.Buttons & PSP_CTRL_START) {
273323
state = 1;
@@ -276,6 +326,40 @@ auto main() -> int {
276326
running = 0;
277327
}
278328

329+
if (latchData.uiBreak & PSP_CTRL_TRIANGLE){
330+
if (mySkin + 1 > (sizeof(skins)/sizeof(*skins))-1) {
331+
mySkin = 0;
332+
} else {
333+
mySkin++;
334+
}
335+
if(mySkin != 0){
336+
plr_skin = g2dTexLoad(skins[mySkin],G2D_SWIZZLE);
337+
}
338+
}
339+
340+
//cell
341+
g2dBeginRects(tex);
342+
g2dSetColor(RED);
343+
g2dSetScaleWH(50,50);
344+
g2dSetCoordXY(370,132);
345+
massSize = mass / 2;
346+
347+
g2dAdd();
348+
g2dEnd();
349+
350+
// skin (added onto cell if skin is chosen)
351+
if(mySkin != 0){
352+
// apply the skin!
353+
g2dBeginRects(plr_skin);
354+
g2dSetColor(WHITE);
355+
g2dSetScaleWH(50,50);
356+
g2dSetCoordXY(370,132);
357+
358+
g2dAdd();
359+
g2dEnd();
360+
}
361+
362+
279363
g2dFlip(G2D_VSYNC);
280364
}
281365

‎src/main.o

912 Bytes
Binary file not shown.

‎src/title.png

1.76 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.