Skip to content

Commit d576fe8

Browse files
committed
Add th-umb
1 parent 4fd089e commit d576fe8

File tree

13 files changed

+1972
-0
lines changed

13 files changed

+1972
-0
lines changed

th-umb/arcade_description.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A simple 2D sandbox game made for the thumby! Hence the name TH-UMB!
2+
3+
Disclaimer ( THIS IS A DEMAKE OF UMB MADE BY LURPLE!!! )
4+
If you need any info about the game, i would highly recommend joining the thumby discord server and looking for the thread named " TH-UMB ( UMB De/Remake ) "!
5+
This game will "hopefully" eventually have a modular support for modding in the future for yall to add whatever you want!
6+
7+
" Creator of Foxgine! "
8+
9+
Author: PresentFox
10+
Version: 1.0
11+
License: None

th-umb/charSave.json

Whitespace-only changes.

th-umb/crafting.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
_E='Furnace'
2+
_D='Amethyst'
3+
_C='Bucket+'
4+
_B='Bucket'
5+
_A='Pickaxe'
6+
class Craft:
7+
def __init__(self,logic,b):self.enabled=[1,1];self.logic=logic;self.craftSpot=0;self.buttons=b;self.amt=0;self.items=[[_A,'Axe','Step','Slab',_B,_C,'Bed'],[_D,'Ruby','Coal'],['Table',_E]]
8+
@micropython.native
9+
def checkForCraft(self):
10+
posX,posY=self.logic.pInt[0],self.logic.pInt[1]
11+
if posX==0:posX=1
12+
elif posX==19:posX=18
13+
if posY==0:posY=1
14+
elif posY==9:posY=8
15+
self.enabled=[0,0];step=0;posTypes=[-1,-1,0,-1,1,-1,-1,0,0,0,1,0,-1,1,0,1,1,1]
16+
for i in range(9):
17+
if self.logic.world[(posY+posTypes[step+1])*20+(posX+posTypes[step])]==16:self.enabled[0]=1
18+
if self.logic.world[(posY+posTypes[step+1])*20+(posX+posTypes[step])]==17:self.enabled[1]=1
19+
step+=2
20+
self.crafting()
21+
@micropython.native
22+
def tableCraft(self,check,item):
23+
slot=[-1]*len(check)
24+
for i in range(len(self.logic.inv)):
25+
if self.logic.inv[i]!=0:
26+
for l in range(len(check)):
27+
if self.logic.inv[i][0]==check[l][0]:slot[l]=i
28+
for l in range(len(slot)):
29+
if slot[l]==-1:return 0
30+
@micropython.native
31+
def checker():
32+
for i in range(len(slot)):
33+
if self.logic.inv[slot[i]][1]>=check[i][1]:
34+
self.logic.inv[slot[i]][1]-=check[i][1]
35+
if self.logic.inv[slot[i]][1]<=0:self.logic.inv[slot[i]]=0
36+
return 1
37+
return 0
38+
for l in range(len(self.logic.inv)):
39+
if self.logic.inv[l]==0:
40+
if checker()==1:self.logic.inv[l]=[item,1]
41+
self.logic.display.fill(2);return
42+
elif self.logic.inv[l][0]==item:
43+
if checker()==1:self.logic.inv[l][1]+=1
44+
self.logic.display.fill(2);return
45+
@micropython.native
46+
def crafting(self):
47+
if self.logic.invArea!=0:
48+
self.amt=len(self.items[self.logic.invArea-1])-1
49+
if self.amt<self.craftSpot:self.craftSpot=self.amt
50+
if self.buttons.buttonL.justPressed():self.craftSpot=max(0,self.craftSpot-1)
51+
if self.buttons.buttonR.justPressed():self.craftSpot=min(self.amt,self.craftSpot+1)
52+
if self.logic.invArea==1 and self.enabled[0]==1:
53+
self.logic.display.drawText(self.items[0][self.craftSpot],5,32,1);self.logic.display.drawText('#',66,32,1);check=[]
54+
if self.buttons.buttonB.justPressed():
55+
if self.items[0][self.craftSpot]==_A:check=[[1,3],[3,5]];self.tableCraft(check,7)
56+
elif self.items[0][self.craftSpot]=='Axe':check=[[1,3],[3,4]];self.tableCraft(check,8)
57+
elif self.items[0][self.craftSpot]=='Slab':check=[[1,2]];self.tableCraft(check,9)
58+
elif self.items[0][self.craftSpot]=='Step':check=[[17,5]];self.tableCraft(check,10)
59+
elif self.items[0][self.craftSpot]==_B:check=[[5,3]];self.tableCraft(check,14)
60+
elif self.items[0][self.craftSpot]==_C:check=[[5,3],[6,3]];self.tableCraft(check,15)
61+
elif self.items[0][self.craftSpot]=='Bed':check=[[1,3],[5,3]];self.tableCraft(check,13)
62+
return
63+
elif self.logic.invArea==1 and self.enabled[0]==0:self.logic.display.drawText('Need #',5,32,1);return
64+
if self.logic.invArea==2 and self.enabled[1]==1:
65+
self.logic.display.drawText(self.items[1][self.craftSpot],5,32,1);self.logic.display.drawText('0',66,32,1);check=[]
66+
if self.buttons.buttonB.justPressed():
67+
if self.items[1][self.craftSpot]==_D:check=[[4,2]];self.tableCraft(check,6)
68+
elif self.items[1][self.craftSpot]=='Ruby':check=[[4,3]];self.tableCraft(check,5)
69+
elif self.items[1][self.craftSpot]=='Coal':check=[[1,1]];self.tableCraft(check,4)
70+
return
71+
elif self.logic.invArea==2 and self.enabled[1]==0:self.logic.display.drawText('Need 0',5,32,1);return
72+
if self.logic.invArea==3:
73+
self.logic.display.drawText(self.items[2][self.craftSpot],5,32,1);self.logic.display.drawText('+',66,32,1);check=[]
74+
if self.buttons.buttonB.justPressed():
75+
if self.items[2][self.craftSpot]=='Table':check=[[1,4]];self.tableCraft(check,12)
76+
elif self.items[2][self.craftSpot]==_E:check=[[3,4]];self.tableCraft(check,11)
77+
return

th-umb/emulator_video.webm

748 KB
Binary file not shown.

th-umb/entityLogic.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import random
2+
from math import*
3+
import sys
4+
sys.path.append('/Games/th-umb')
5+
class Logic:
6+
def __init__(self,g,e,s):self.gLogic=g;self.entities=e;self.sprites=s
7+
@micropython.native
8+
def entityChecker(self,invSlot):
9+
for entity in self.entities:
10+
if entity[2]==0:self.fish(self.entities.index(entity))
11+
elif entity[2]==1:self.bull(self.entities.index(entity))
12+
elif entity[2]==2:self.trader(self.entities.index(entity),invSlot)
13+
elif entity[2]==3:self.zombie(self.entities.index(entity))
14+
elif entity[2]==4:self.seed(self.entities.index(entity))
15+
@micropython.native
16+
def seed(self,i):
17+
entity=self.entities[i];entity[3][1]+=1
18+
if entity[3][1]>2:entity[3][1]=0;entity[3][0]+=1
19+
if entity[3][0]>10:self.gLogic.world[entity[1]*20+entity[0]]=random.randint(1,2);self.entities.remove(entity)
20+
xTree=entity[0]*6+self.gLogic.cInt[0];yTree=entity[1]*8+self.gLogic.cInt[1];self.gLogic.display.drawFilledRectangle(xTree,yTree,5,7,0);self.gLogic.display.drawText('s',xTree,yTree,2)
21+
@micropython.native
22+
def zombie(self,i):
23+
entity=self.entities[i];zombie_sprite=self.sprites.zombie
24+
if-1>=zombie_sprite.x>=72 or-1>=zombie_sprite.y>=40:return
25+
radius=[self.gLogic.pInt[0]-entity[0],self.gLogic.pInt[1]-entity[1]]
26+
if entity[3]>0:entity[3]-=1
27+
newTx=newTy=0
28+
if 5>radius[0]>-5 and 5>radius[1]>-5:
29+
newTx=entity[0];newTy=entity[1]
30+
if radius[0]>0:newTx+=1
31+
elif radius[0]<-0:newTx-=1
32+
if radius[1]>0:newTy+=1
33+
elif radius[1]<-0:newTy-=1
34+
ww=20;wh=len(self.gLogic.world)//ww
35+
if 0<=newTx<ww and 0<=newTy<wh:
36+
if entity[3]<=0 and self.gLogic.world[newTy*ww+newTx]not in{1,2,3,5,7,8,12,13,14,16,17,21}:entity[0]=newTx;entity[1]=newTy;entity[3]=5
37+
if radius[0]==0 and radius[1]==0:self.gLogic.hp()
38+
zombie_sprite.x=entity[0]*6+self.gLogic.cInt[0];zombie_sprite.y=entity[1]*8+self.gLogic.cInt[1];self.gLogic.display.drawSprite(zombie_sprite)
39+
@micropython.native
40+
def trader(self,i,invSlot):
41+
entity=self.entities[i];trader_sprite=self.sprites.trader
42+
if-1>=trader_sprite.x>=72 or-1>=trader_sprite.y>=40:return
43+
radius=[self.gLogic.pInt[0]-entity[0],self.gLogic.pInt[1]-entity[1]];entity[3]=0
44+
if entity[4]>0:entity[4]-=1
45+
newTx=newTy=0
46+
if invSlot!=0:
47+
if(5>radius[0]>-5 and 5>radius[1]>-5)and invSlot[0]in{5,6}:
48+
entity[3]=1;newTx=entity[0];newTy=entity[1]
49+
if radius[0]>1:newTx+=1
50+
elif radius[0]<-1:newTx-=1
51+
if radius[1]>1:newTy+=1
52+
elif radius[1]<-1:newTy-=1
53+
ww=20;wh=len(self.gLogic.world)//ww
54+
if 0<=newTx<ww and 0<=newTy<wh:
55+
if entity[4]<=0 and self.gLogic.world[newTy*ww+newTx]not in{1,2,3,5,7,8,12,13,14,16,17,21}:entity[0]=newTx;entity[1]=newTy;entity[4]=5
56+
if(radius[0]==0 and radius[1]==0)and invSlot[0]in{5,6}:
57+
invSlot[1]-=1;rand=random.randint(1,8)
58+
for i in range(random.randint(1,2)):
59+
if rand not in{5,6}:self.gLogic.mine_place(rand)
60+
self.gLogic.pInt=[random.randint(self.gLogic.pInt[0]-1,self.gLogic.pInt[0]+1),random.randint(self.gLogic.pInt[1]-1,self.gLogic.pInt[1]+1)]
61+
trader_sprite.x=entity[0]*6+self.gLogic.cInt[0];trader_sprite.y=entity[1]*8+self.gLogic.cInt[1];trader_sprite.setFrame(entity[3]);self.gLogic.display.drawSprite(trader_sprite)
62+
@micropython.native
63+
def bull(self,i):
64+
entity=self.entities[i];bull_sprite=self.sprites.bull
65+
if-1>=bull_sprite.x>=72 or-1>=bull_sprite.y>=40:return
66+
if entity[3]==0:
67+
player_x,player_y=self.gLogic.pInt[0],self.gLogic.pInt[1];bull_x,bull_y=entity[0],entity[1];directions=[(1,0),(-1,0),(0,1),(0,-1)]
68+
for(dx,dy)in directions:
69+
for dist in range(1,5):
70+
new_x=bull_x+dx*dist;new_y=bull_y+dy*dist
71+
if new_x==player_x and new_y==player_y:entity[4]=[dx,dy];entity[3]=1;break
72+
elif entity[3]==1:
73+
move_x,move_y=entity[4][0],entity[4][1];new_bull_x=entity[0]+move_x;new_bull_y=entity[1]+move_y
74+
if(new_bull_x<0 or new_bull_x>=20)or(new_bull_y<0 or new_bull_y>=10):entity[3]=0;return
75+
if self.gLogic.world[new_bull_y*20+new_bull_x]not in{1,2,3,5,7,8,12,13,14,16,17,21}:entity[0],entity[1]=new_bull_x,new_bull_y
76+
else:entity[3]=0
77+
if entity[0]==self.gLogic.pInt[0]and entity[1]==self.gLogic.pInt[1]:self.gLogic.hp()
78+
bull_sprite.x=entity[0]*6+self.gLogic.cInt[0];bull_sprite.y=entity[1]*8+self.gLogic.cInt[1];bull_sprite.setFrame(entity[3]);self.gLogic.display.drawSprite(bull_sprite)
79+
@micropython.native
80+
def fish(self,i):
81+
entity=self.entities[i];entity[3]-=1;fish_sprite=self.sprites.fish
82+
if-1>=fish_sprite.x>=72 or-1>=fish_sprite.y>=40:return
83+
if entity[3]<=0:
84+
entity[3]=10;directions=[(1,0),(-1,0),(0,1),(0,-1)];move=[]
85+
for(dx,dy)in directions:
86+
new_x=entity[0]+dx;new_y=entity[1]+dy
87+
if 0<=new_x<=19 and 0<=new_y<=9 and self.gLogic.world[new_y*20+new_x]==3:move.append((new_x,new_y))
88+
if move:self.gLogic.counting();random.seed(self.gLogic.counter);rand_move=random.choice(move);entity[0],entity[1]=rand_move
89+
fish_sprite.x=entity[0]*6+self.gLogic.cInt[0];fish_sprite.y=entity[1]*8+self.gLogic.cInt[1];fish_sprite.setFrame(1 if entity[3]>7 else 0);self.gLogic.display.drawSprite(fish_sprite)

0 commit comments

Comments
 (0)