mirror of
https://github.com/m4rcel-lol/m5rcode-ubuntu.git
synced 2025-12-06 19:13:57 +05:30
Uploading m5rcode Ubuntu Port to the repo
This commit is contained in:
46
files/m5rcel.m5r
Normal file
46
files/m5rcel.m5r
Normal file
@@ -0,0 +1,46 @@
|
||||
<?py
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
msg = ''.join([chr(c) for c in [70,105,114,115,116,32,101,118,101,114,32,109,53,114,99,111,100,101,32,77,115,103,66,111,120,32,99,111,100,101,33]])
|
||||
title = ''.join([chr(c) for c in [109,53,114,99,111,100,101,32,77,115,103,66,111,120]])
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
messagebox.showinfo(title, msg)
|
||||
?>
|
||||
<?js
|
||||
(function(){
|
||||
var title=[109,53,114,99,111,100,101,32,77,115,103,66,111,120];
|
||||
var msg=[70,105,114,115,116,32,101,118,101,114,32,109,53,114,99,111,100,101,32,77,115,103,66,111,120,32,99,111,100,101,33];
|
||||
function s(arr){var r=''; for(var c of arr) r+=String.fromCharCode(c); return r;}
|
||||
alert(msg.join(''));
|
||||
})();
|
||||
?>
|
||||
<?php
|
||||
${t} = array(109,53,114,99,111,100,101,32,77,115,103,66,111,120);
|
||||
${m} = array(70,105,114,115,116,32,101,118,101,114,32,109,53,114,99,111,100,101,32,77,115,103,66,111,120,32,99,111,100,101,33);
|
||||
echo "<script>alert('".implode(array_map('chr',${m}))."');</script>";
|
||||
?>
|
||||
<?css
|
||||
/* MsgBox style */
|
||||
body { background: #111; color: #0f0; font-family: monospace; }
|
||||
?>
|
||||
<?cs
|
||||
string title = string.Join("", new int[] {109,53,114,99,111,100,101,32,77,115,103,66,111,120}.Select(c => (char)c));
|
||||
string msg = string.Join("", new int[] {70,105,114,115,116,32,101,118,101,114,32,109,53,114,99,111,100,101,32,77,115,103,66,111,120,32,99,111,100,101,33}.Select(c => (char)c));
|
||||
System.Windows.Forms.MessageBox.Show(msg, title);
|
||||
?>
|
||||
<?cpp
|
||||
#include <windows.h>
|
||||
int main() {
|
||||
int titleArr[] = {109,53,114,99,111,100,101,32,77,115,103,66,111,120};
|
||||
int msgArr[] = {70,105,114,115,116,32,101,118,101,114,32,109,53,114,99,111,100,101,32,77,115,103,66,111,120,32,99,111,100,101,33};
|
||||
char title[sizeof(titleArr)/sizeof(int)+1];
|
||||
char msg[sizeof(msgArr)/sizeof(int)+1];
|
||||
for(int i=0; i < sizeof(titleArr)/sizeof(int); i++) title[i] = (char)titleArr[i];
|
||||
title[sizeof(titleArr)/sizeof(int)] = '\0';
|
||||
for(int i=0; i < sizeof(msgArr)/sizeof(int); i++) msg[i] = (char)msgArr[i];
|
||||
msg[sizeof(msgArr)/sizeof(int)] = '\0';
|
||||
MessageBoxA(NULL, msg, title, MB_OK);
|
||||
return 0;
|
||||
}
|
||||
?>
|
||||
288
files/maze.m5r
Normal file
288
files/maze.m5r
Normal file
@@ -0,0 +1,288 @@
|
||||
<?py
|
||||
# -*- coding: utf-8 -*-
|
||||
import tkinter as _tk, math as _m, random as _r
|
||||
import math
|
||||
import random
|
||||
|
||||
def _gen_backrooms(_lv):
|
||||
_sz = min(18 + _lv*4, 60)
|
||||
_mp = [[1]*_sz for _ in range(_sz)]
|
||||
def _carve(x, y):
|
||||
_mp[y][x] = 0
|
||||
dirs = [(0,2), (0,-2), (2,0), (-2,0)]
|
||||
_r.shuffle(dirs)
|
||||
for dx,dy in dirs:
|
||||
nx,ny=x+dx,y+dy
|
||||
if 2<=nx<_sz-2 and 2<=ny<_sz-2 and _mp[ny][nx]==1:
|
||||
_mp[y+dy//2][x+dx//2]=0
|
||||
_carve(nx,ny)
|
||||
startx = _sz//2
|
||||
starty = _sz//2
|
||||
_carve(startx, starty)
|
||||
for _ in range(_sz*_sz//7):
|
||||
_x = _r.randint(2,_sz-3)
|
||||
_y = _r.randint(2,_sz-3)
|
||||
if _r.random()<0.45: _mp[_y][_x]=0
|
||||
_mp[starty][startx]=0
|
||||
_mp[_sz-3][_sz-3]=0
|
||||
_mp[_sz-2][_sz-2]=2
|
||||
return _mp
|
||||
|
||||
class _BACKROOMS:
|
||||
def __init__(self):
|
||||
self._rt=_tk.Tk()
|
||||
self._rt.title("BACKROOMS MAZE - M5RCode")
|
||||
self._W,self._H=1200,820
|
||||
self._cv=_tk.Canvas(self._rt,bg="#12131a",width=self._W,height=self._H)
|
||||
self._cv.pack(fill="both",expand=True)
|
||||
self._game_state="main"
|
||||
self._fullscreen = False
|
||||
self._mouse_locked = False
|
||||
self._reset_game()
|
||||
self._keys=set()
|
||||
self._mouse_x_last = None
|
||||
self._menu_btn_area = None
|
||||
self._rt.bind("<Configure>",self._resize)
|
||||
self._rt.bind("<KeyPress>",self._kd)
|
||||
self._rt.bind("<KeyRelease>",self._ku)
|
||||
self._cv.bind("<Button-1>", self._mouse_btn) # bind to canvas, not root!
|
||||
self._rt.bind("<Escape>",self._esc)
|
||||
self._rt.bind("<F11>", self._toggle_fullscreen)
|
||||
self._rt.bind("<Motion>", self._mouse_move)
|
||||
self._tick()
|
||||
self._rt.mainloop()
|
||||
|
||||
def _reset_game(self,level=1):
|
||||
self._level=level
|
||||
self._map=_gen_backrooms(level)
|
||||
self._sz=len(self._map)
|
||||
self._px,self._py=self._sz//2+0.5,self._sz//2+0.5
|
||||
self._pa=_m.pi/4
|
||||
self._levelup_msg=0
|
||||
|
||||
def _resize(self,e): self._W,self._H=e.width,e.height
|
||||
|
||||
def _mouse_btn(self,e):
|
||||
if self._game_state=="main":
|
||||
# only start if inside start button area
|
||||
if self._menu_btn_area:
|
||||
x0, y0, x1, y1 = self._menu_btn_area
|
||||
if x0 <= e.x <= x1 and y0 <= e.y <= y1:
|
||||
self._game_state="play"
|
||||
self._lock_mouse()
|
||||
elif self._game_state=="pause":
|
||||
self._lock_mouse()
|
||||
|
||||
def _lock_mouse(self):
|
||||
if not self._mouse_locked:
|
||||
self._mouse_locked=True
|
||||
self._rt.config(cursor="none")
|
||||
self._cv.grab_set()
|
||||
self._mouse_x_last = None
|
||||
|
||||
def _unlock_mouse(self,e=None):
|
||||
self._mouse_locked=False
|
||||
self._rt.config(cursor="")
|
||||
self._cv.grab_release()
|
||||
self._mouse_x_last = None
|
||||
|
||||
def _mouse_move(self,e):
|
||||
if self._mouse_locked and self._game_state=="play":
|
||||
if self._mouse_x_last is not None:
|
||||
dx = e.x - self._mouse_x_last
|
||||
self._pa += dx * 0.0067
|
||||
self._mouse_x_last = e.x
|
||||
else:
|
||||
self._mouse_x_last = None
|
||||
|
||||
def _esc(self,e):
|
||||
if self._game_state=="play" and self._mouse_locked:
|
||||
self._unlock_mouse()
|
||||
self._game_state="pause"
|
||||
elif self._game_state=="pause":
|
||||
self._game_state="main"
|
||||
elif self._game_state=="main":
|
||||
self._rt.destroy()
|
||||
|
||||
def _toggle_fullscreen(self,e=None):
|
||||
self._fullscreen = not self._fullscreen
|
||||
self._rt.attributes("-fullscreen", self._fullscreen)
|
||||
|
||||
def _brighten(self, col, factor):
|
||||
if col.startswith('#') and len(col)==7:
|
||||
r,g,b=int(col[1:3],16),int(col[3:5],16),int(col[5:7],16)
|
||||
r,g,b=min(255,int(r*factor)),min(255,int(g*factor)),min(255,int(b*factor))
|
||||
return f'#{r:02x}{g:02x}{b:02x}'
|
||||
return col
|
||||
def _darken(self, col, factor):
|
||||
if col.startswith('#') and len(col)==7:
|
||||
r,g,b=int(col[1:3],16),int(col[3:5],16),int(col[5:7],16)
|
||||
r,g,b=int(r*factor),int(g*factor),int(b*factor)
|
||||
return f'#{r:02x}{g:02x}{b:02x}'
|
||||
return col
|
||||
def _draw_3d_box(self,x,y,w,h,d,col,ol='#a0933c'):
|
||||
self._cv.create_rectangle(x,y,x+w,y+h,fill=col,outline=ol,width=2)
|
||||
pts_top=[(x,y),(x+d,y-d),(x+w+d,y-d),(x+w,y)]
|
||||
self._cv.create_polygon(pts_top,fill=self._brighten(col,1.22),outline=ol,width=1)
|
||||
pts_r=[(x+w,y),(x+w+d,y-d),(x+w+d,y+h-d),(x+w,y+h)]
|
||||
self._cv.create_polygon(pts_r,fill=self._darken(col,0.75),outline=ol,width=1)
|
||||
|
||||
def _draw_hud(self):
|
||||
y = self._H-80
|
||||
self._draw_3d_box(0,y,self._W,80,6,"#fef2a0","#d8c944")
|
||||
self._cv.create_text(120,y+25,text=f"LEVEL: {self._level}",font=("Consolas",24,"bold"),fill="#665100")
|
||||
self._cv.create_text(self._W//2,y+25,text="FIND THE BLUE EXIT!",font=("Consolas",20,"bold"),fill="#3e79ff")
|
||||
self._cv.create_text(self._W-150,y+25,text=f"SIZE: {self._sz}x{self._sz}",font=("Consolas",16,"bold"),fill="#d8b144")
|
||||
|
||||
def _raycast(self,a):
|
||||
x,y = self._px,self._py
|
||||
dx,dy = _m.cos(a)*.05,_m.sin(a)*.05
|
||||
for d in range(1,400):
|
||||
x+=dx; y+=dy
|
||||
mx,my=int(x),int(y)
|
||||
if mx<0 or my<0 or mx>=self._sz or my>=self._sz:
|
||||
return d/20,1,'#c7bc54'
|
||||
cell = self._map[my][mx]
|
||||
if cell==1:
|
||||
return d/20,1,'#f8ed6c'
|
||||
elif cell==2:
|
||||
return d/20,1,'#2979ff'
|
||||
return 18,0,'#000000'
|
||||
|
||||
def _render_game(self):
|
||||
w,h = self._W,self._H
|
||||
self._cv.delete('all')
|
||||
for i in range(h//2):
|
||||
b=235-i//7;sh=f"#{b:02x}{b:02x}{(b//2)+85:02x}"
|
||||
self._cv.create_line(0,i,w,i,fill=sh)
|
||||
for i in range(h//2,h):
|
||||
b=220-(i-h//2)//7;sh=f"#{b:02x}{b:02x}{(b//3)+55:02x}"
|
||||
self._cv.create_line(0,i,w,i,fill=sh)
|
||||
rays=270
|
||||
for i in range(rays):
|
||||
a=self._pa-_m.pi/2.3 + (_m.pi/1.15*i)/(rays-1)
|
||||
d,wall,wall_color=self._raycast(a)
|
||||
d = max(.08, d*_m.cos(a-self._pa))
|
||||
hwall=int(h*0.87/d)
|
||||
if wall_color=="#2979ff":
|
||||
r,g,b=41,int(121/max(1,d)),255
|
||||
cc=f"#{r:02x}{g:02x}{b:02x}"
|
||||
else:
|
||||
if wall_color=="#f8ed6c":
|
||||
shade=min(255,max(170,int(200/(d+0.8))))
|
||||
cc=f"#{shade:02x}{shade:02x}{int(shade*0.88):02x}"
|
||||
else:
|
||||
cc=wall_color
|
||||
x=int(i*w/rays)
|
||||
self._cv.create_rectangle(x,h//2-hwall//2-10,x+int(w/rays+1),h//2+hwall//2,fill=cc,outline="")
|
||||
self._draw_hud()
|
||||
cx,cy=w-80,80
|
||||
self._cv.create_oval(cx-30,cy-30,cx+30,cy+30,fill="#aaa924",outline="#ffffff",width=2)
|
||||
arrow_x = cx + 20*_m.cos(self._pa)
|
||||
arrow_y = cy + 20*_m.sin(self._pa)
|
||||
self._cv.create_line(cx,cy,arrow_x,arrow_y,fill="#2979ff",width=3)
|
||||
self._cv.create_text(cx,cy+45,text="N",font=("Consolas",12,"bold"),fill="#665100")
|
||||
if self._game_state=="pause":
|
||||
self._draw_3d_box(w//2-150,h//2-70,300,69,10,"#23232a","#343434")
|
||||
self._cv.create_text(w//2,h//2-37,text="PAUSED",font=("Consolas",28,"bold"),fill="#ffee44")
|
||||
self._cv.create_text(w//2,h//2+7,text="ESC to resume",font=("Consolas",13,"bold"),fill="#2979ff")
|
||||
if self._levelup_msg>0:
|
||||
self._draw_3d_box(w//2-180,h//2-60,360,50,12,"#2979ff","#ffffff")
|
||||
self._cv.create_text(w//2,h//2-35,text=f"LEVEL {self._level-1} ESCAPED!",font=("Consolas",18,"bold"),fill="#665100")
|
||||
self._levelup_msg-=1
|
||||
|
||||
def _tick(self):
|
||||
if self._game_state=="play":
|
||||
self._step()
|
||||
self._render_game()
|
||||
elif self._game_state=="main":
|
||||
self._render_menu()
|
||||
elif self._game_state=="pause":
|
||||
self._render_game()
|
||||
self._rt.after(28,self._tick)
|
||||
|
||||
def _render_menu(self):
|
||||
w,h=self._W,self._H
|
||||
self._cv.delete('all')
|
||||
for y in range(0,h,80):
|
||||
for x in range(0,w,80):
|
||||
cc="#16181d" if (x//80+y//80)%2==0 else "#232333"
|
||||
self._cv.create_rectangle(x,y,x+80,y+80,fill=cc,width=0)
|
||||
self._draw_3d_box(w//2-200,h//3-100,400,80,25,"#232333","#111833")
|
||||
self._cv.create_text(w//2,h//3-60,text="BACKROOMS MAZE",fill="#d8d8ef",font=("Consolas",36,"bold"))
|
||||
self._draw_3d_box(w//2-180,h//3,360,50,15,"#282848","#45455a")
|
||||
self._cv.create_text(w//2,h//3+25,text="2.5D LIMINAL ADVENTURE",fill="#bcbcd2",font=("Consolas",21,"bold"))
|
||||
# Start button area, properly recorded for click test
|
||||
btn_x0,btn_y0=w//2-120,h//2+80
|
||||
btn_x1,btn_y1=w//2+120,h//2+135
|
||||
self._menu_btn_area = (btn_x0,btn_y0,btn_x1,btn_y1)
|
||||
self._draw_3d_box(btn_x0,btn_y0,240,55,12,"#1199cc","#ffffff")
|
||||
self._cv.create_text(w//2,h//2+107,text="START",fill="#ffffff",font=("Consolas",18,"bold"))
|
||||
self._cv.create_text(w//2,h-78,text="Navigate the yellow maze. Find the BLUE EXIT!",font=("Consolas",16),fill="#2979ff")
|
||||
self._cv.create_text(w//2,h-50,text="WASD: Move | Mouse: Look | Click: Lock Camera | F11: Fullscreen",font=("Consolas",14),fill="#bcbcd2")
|
||||
def _move_smooth(self,dx,dy):
|
||||
def is_blocked(x,y):
|
||||
mx,my=int(x),int(y)
|
||||
return mx<0 or my<0 or mx>=self._sz or my>=self._sz or self._map[my][mx]==1
|
||||
nx,ny = self._px+dx, self._py+dy
|
||||
if not is_blocked(nx,ny): self._px,self._py=nx,ny
|
||||
else:
|
||||
if not is_blocked(self._px,ny): self._py=ny
|
||||
elif not is_blocked(nx,self._py): self._px=nx
|
||||
def _step(self):
|
||||
spd,dx,dy=0.12,0,0
|
||||
if 'w' in self._keys: dx+=_m.cos(self._pa)*spd; dy+=_m.sin(self._pa)*spd
|
||||
if 's' in self._keys: dx-=_m.cos(self._pa)*spd*.8; dy-=_m.sin(self._pa)*spd*.8
|
||||
if 'a' in self._keys: dx+=_m.cos(self._pa-_m.pi/2)*spd*.7; dy+=_m.sin(self._pa-_m.pi/2)*spd*.7
|
||||
if 'd' in self._keys: dx+=_m.cos(self._pa+_m.pi/2)*spd*.7; dy+=_m.sin(self._pa+_m.pi/2)*spd*.7
|
||||
self._move_smooth(dx,dy)
|
||||
mx,my=int(self._px),int(self._py)
|
||||
for check_x in range(max(0, mx-1), min(self._sz, mx+2)):
|
||||
for check_y in range(max(0, my-1), min(self._sz, my+2)):
|
||||
if self._map[check_y][check_x] == 2:
|
||||
distance = math.sqrt((self._px - (check_x+0.5))**2 + (self._py - (check_y+0.5))**2)
|
||||
if distance < 1.2:
|
||||
self._reset_game(self._level + 1)
|
||||
self._levelup_msg = 80
|
||||
return
|
||||
def _kd(self,e):
|
||||
if self._game_state=="play" and self._mouse_locked:
|
||||
self._keys.add(e.keysym.lower())
|
||||
if e.keysym.lower()=='left':
|
||||
self._pa-=_m.pi/20
|
||||
if e.keysym.lower()=='right':
|
||||
self._pa+=_m.pi/20
|
||||
if e.keysym.lower()=="f11":
|
||||
self._toggle_fullscreen()
|
||||
def _ku(self,e):
|
||||
self._keys.discard(e.keysym.lower())
|
||||
|
||||
_BACKROOMS()
|
||||
?>
|
||||
|
||||
<?js
|
||||
console.log("BACKROOMS MAZE 2.5D M5RCode");
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo "BACKROOMS MAZE 2.5D M5RCode\n";
|
||||
?>
|
||||
|
||||
<?cs
|
||||
using System;
|
||||
class _M{
|
||||
static void Main(){ Console.WriteLine("BACKROOMS MAZE 2.5D M5RCode"); }
|
||||
}
|
||||
?>
|
||||
|
||||
<?cpp
|
||||
#include <iostream>
|
||||
int main(){ std::cout<<"BACKROOMS MAZE 2.5D M5RCode"<<std::endl; return 0;}
|
||||
?>
|
||||
|
||||
<?css
|
||||
body{background:#16181d;color:#d8d8ef;font-family:'Courier New',monospace;overflow:hidden;}
|
||||
canvas{cursor:crosshair;image-rendering:pixelated;}
|
||||
.maze-wall{filter:contrast(1.1);}
|
||||
.maze-exit{filter:brightness(1.4) saturate(1.7);}
|
||||
?>
|
||||
195
files/snake.m5r
Normal file
195
files/snake.m5r
Normal file
@@ -0,0 +1,195 @@
|
||||
<?py
|
||||
# M5RCode Python Block: OBFUSCATED - 3D Snake Game (Tkinter)
|
||||
|
||||
import tkinter as _tk
|
||||
import random as _r
|
||||
import collections as _c
|
||||
|
||||
_bW=14
|
||||
_bH=14
|
||||
_cS=26
|
||||
_iSL=4
|
||||
_gTI=110
|
||||
|
||||
def _iso(_x,_y):
|
||||
_sx=(_x-_y)*_cS*0.52+_bW*_cS/2
|
||||
_sy=((_x+_y)*0.37)*_cS*0.52+54
|
||||
return _sx,_sy
|
||||
|
||||
def _cube(_cv,_x,_y,_col,_head=False):
|
||||
_ox,_oy=_iso(_x,_y)
|
||||
_T=[(_ox,_oy),(_ox+_cS*0.5,_oy-_cS*0.33),(_ox+_cS,_oy),(_ox+_cS*0.5,_oy+_cS*0.35)]
|
||||
_L=[(_ox,_oy),(_ox+_cS*0.5,_oy+_cS*0.35),(_ox+_cS*0.5,_oy+_cS*0.98),(_ox,_oy+_cS*0.63)]
|
||||
_R=[(_ox+_cS,_oy),(_ox+_cS*0.5,_oy+_cS*0.35),(_ox+_cS*0.5,_oy+_cS*0.98),(_ox+_cS,_oy+_cS*0.63)]
|
||||
_cv.create_polygon(_T,fill=_col if not _head else "#ffe257",outline="#1c2127",width=2)
|
||||
_cv.create_polygon(_L,fill="#20c750",outline="#1c2127",width=1)
|
||||
_cv.create_polygon(_R,fill="#147d2d",outline="#1c2127",width=1)
|
||||
if _head:
|
||||
_cv.create_oval(_ox+_cS*0.32,_oy+_cS*0.09,_ox+_cS*0.59,_oy+_cS*0.28,fill="#2a2d35",outline="#fff",width=1)
|
||||
|
||||
def _food3d(_cv,_x,_y):
|
||||
_ox,_oy=_iso(_x,_y)
|
||||
_r=_cS//2
|
||||
_cv.create_oval(_ox+_cS*0.26-_r/2,_oy+_cS*0.16-_r/2,_ox+_cS*0.26+_r/2,_oy+_cS*0.16+_r/2,
|
||||
fill="#ff0039",outline="#7d2034",width=2)
|
||||
_cv.create_oval(_ox+_cS*0.28-_r/6,_oy+_cS*0.13-_r/6,_ox+_cS*0.28+_r/6,_oy+_cS*0.13+_r/6,
|
||||
fill="#fff",outline="#fff",width=0)
|
||||
|
||||
class _SG:
|
||||
def __init__(self,_m):
|
||||
self._m=_m
|
||||
self._m.title(''.join([chr(_c) for _c in [77,53,82,67,111,100,101,32,51,68,32,83,110,97,107,101]]))
|
||||
self._m.resizable(False,False)
|
||||
self._gF=_tk.Frame(self._m,bg='#22223b',padx=20,pady=15,highlightbackground="#363857",highlightthickness=2,bd=0,relief='flat')
|
||||
self._gF.pack(expand=True,fill='both')
|
||||
self._tL=_tk.Label(self._gF,text='M5RCode 3D Snake',font=('Inter',22,'bold'),fg='#4CAF50',bg='#22223b')
|
||||
self._tL.pack(pady=(0,8))
|
||||
self._s=0
|
||||
self._sL=_tk.Label(self._gF,text=f"Score: {self._s}",font=('Inter',16,'bold'),fg='#f39c12',bg='#22223b')
|
||||
self._sL.pack(pady=(0,8))
|
||||
self._c=_tk.Canvas(self._gF,width=_bW*_cS+56,height=_bH*_cS+88,bg='#151526',
|
||||
highlightbackground="#23243c",highlightthickness=5,bd=0,relief='flat')
|
||||
self._c.pack()
|
||||
self._sn=_c.deque()
|
||||
self._f=None
|
||||
self._d='Right'
|
||||
self._gO=False
|
||||
self._gR=False
|
||||
for _k in ['<Left>','<Right>','<Up>','<Down>','w','a','s','d']:
|
||||
self._m.bind(_k,self._cD)
|
||||
self._sB=_tk.Button(self._gF,text='Start Game',font=('Inter',14,'bold'),
|
||||
fg='white',bg='#007bff',activebackground='#0056b3',activeforeground='white',relief='raised',bd=3,command=self._s_g)
|
||||
self._sB.pack(pady=10)
|
||||
self._r_g()
|
||||
|
||||
def _r_g(self):
|
||||
self._sn.clear()
|
||||
for _i in range(_iSL): self._sn.appendleft((_iSL-1-_i,0))
|
||||
self._d='Right'
|
||||
self._s=0
|
||||
self._gO=False
|
||||
self._sL.config(text=f"Score: {self._s}")
|
||||
self._c.delete('all')
|
||||
self._p_f()
|
||||
self._d_e()
|
||||
self._sB.config(text='Start Game',command=self._s_g)
|
||||
self._gR=False
|
||||
|
||||
def _s_g(self):
|
||||
if not self._gR:
|
||||
self._gR=True
|
||||
self._sB.config(text='Restart Game',command=self._r_g)
|
||||
self._g_l()
|
||||
|
||||
def _p_f(self):
|
||||
while 1:
|
||||
_x=_r.randint(0,_bW-1)
|
||||
_y=_r.randint(0,_bH-1)
|
||||
if (_x,_y) not in self._sn:
|
||||
self._f=(_x,_y)
|
||||
break
|
||||
|
||||
def _d_e(self):
|
||||
self._c.delete('all')
|
||||
for _x in range(_bW):
|
||||
for _y in range(_bH):
|
||||
_cube(self._c,_x,_y,"#232b39")
|
||||
if self._f: _food3d(self._c,*self._f)
|
||||
for _i,(_x,_y) in enumerate(self._sn):
|
||||
_cube(self._c,_x,_y,"#00ff00",_head=(_i==0))
|
||||
|
||||
def _cD(self,_e):
|
||||
if self._gO: return
|
||||
_k=_e.keysym
|
||||
if _k=='Left' and self._d!='Right':self._d='Left'
|
||||
elif _k=='Right' and self._d!='Left':self._d='Right'
|
||||
elif _k=='Up' and self._d!='Down':self._d='Up'
|
||||
elif _k=='Down' and self._d!='Up':self._d='Down'
|
||||
elif _k=='a' and self._d!='Right':self._d='Left'
|
||||
elif _k=='d' and self._d!='Left':self._d='Right'
|
||||
elif _k=='w' and self._d!='Down':self._d='Up'
|
||||
elif _k=='s' and self._d!='Up':self._d='Down'
|
||||
|
||||
def _g_l(self):
|
||||
if self._gO or not self._gR: return
|
||||
_hX,_hY=self._sn[0]
|
||||
if self._d=='Up':_nH=(_hX,_hY-1)
|
||||
elif self._d=='Down':_nH=(_hX,_hY+1)
|
||||
elif self._d=='Left':_nH=(_hX-1,_hY)
|
||||
else:_nH=(_hX+1,_hY)
|
||||
if (_nH[0]<0 or _nH[0]>=_bW or _nH[1]<0 or _nH[1]>=_bH) or _nH in self._sn:
|
||||
self._e_g(); return
|
||||
self._sn.appendleft(_nH)
|
||||
if _nH==self._f:
|
||||
self._s+=1
|
||||
self._sL.config(text=f"Score: {self._s}")
|
||||
self._p_f()
|
||||
else: self._sn.pop()
|
||||
self._d_e()
|
||||
self._m.after(_gTI,self._g_l)
|
||||
|
||||
def _e_g(self):
|
||||
self._gO=True
|
||||
self._gR=False
|
||||
self._c.create_text(self._c.winfo_width()/2,self._c.winfo_height()/2,
|
||||
text="GAME OVER!",font=('Inter',28,'bold'),fill='red')
|
||||
print(f"<?py> Game Over! Final Score: {self._s}")
|
||||
|
||||
if __name__=='__main__':
|
||||
_rt=_tk.Tk()
|
||||
_gm=_SG(_rt)
|
||||
_rt.mainloop()
|
||||
?>
|
||||
<?js
|
||||
# M5RCode JavaScript Block: OBFUSCATED
|
||||
(function(){
|
||||
var _a=''.concat([51,68,32,83,110,97,107,101,32,74,83,32,66,108,111,99,107]); // "3D Snake JS Block"
|
||||
var _b=''.concat([60,63,106,115,62]);
|
||||
console.log(_b+_a);
|
||||
})();
|
||||
?>
|
||||
<?php
|
||||
# M5RCode PHP Block: OBFUSCATED
|
||||
${_a}=array();
|
||||
function _b(${_c},${_d}){
|
||||
global ${_a};
|
||||
${_a}[]=[''.join([chr(_e) for _e in [116,105,109,101,115,116,97,109,112]])=>microtime(true),
|
||||
''.join([chr(_e) for _e in [101,118,101,110,116]])=>${_c},
|
||||
''.join([chr(_e) for _e in [100,97,116,97]])=>${_d}];
|
||||
}
|
||||
_b(''.join([chr(_e) for _e in [77,53,82,67,111,100,101,95,80,72,80,95,76,111,97,100,101,100]]),
|
||||
[''.join([chr(_e) for _e in [109,101,115,115,97,103,101]])=>''.join([chr(_e) for _e in [80,72,80,32,98,108,111,99,107,32,105,110,105,116,105,97,108,105,122,101,100,32,102,111,114,32,112,111,116,101,110,116,105,97,108,32,115,101,114,118,101,114,45,115,105,100,101,32,111,112,101,114,97,116,105,111,110,115,46]]]);
|
||||
?>
|
||||
<?css
|
||||
/* M5RCode CSS Block: OBFUSCATED */
|
||||
/* For Tkinter UI theme, illustrative only */
|
||||
body{font-family:'Inter',sans-serif;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0;
|
||||
background:linear-gradient(135deg,#1a1a2e,#161b3e,#0f3460);color:#e0e0e0;overflow:hidden;}
|
||||
.game-container{background-color:#22223b;border-radius:15px;box-shadow:0 10px 25px rgba(0,0,0,.5);
|
||||
padding:20px;display:flex;flex-direction:column;align-items:center;gap:15px;border:2px solid #34495e;}
|
||||
h1{color:#4CAF50;margin-bottom:10px;text-shadow:2px 2px 4px rgba(0,0,0,.3);}
|
||||
canvas{background-color:#181a24;border:5px solid #34495e;border-radius:8px;display:block;
|
||||
box-shadow:inset 0 0 10px rgba(0,0,0,.5);touch-action:none;-webkit-user-select:none;-ms-user-select:none;user-select:none;}
|
||||
.score-display{font-size:1.5em;font-weight:bold;color:#f39c12;text-shadow:1px 1px 2px rgba(0,0,0,.2);}
|
||||
@media (max-width:600px){.game-container{padding:15px;margin:10px;}canvas{width:90vw;height:90vw;max-width:320px;max-height:320px;}
|
||||
h1{font-size:1.8em;}.score-display{font-size:1.2em;}}
|
||||
?>
|
||||
<?cs
|
||||
// M5RCode C# Block: OBFUSCATED, illustrative
|
||||
using System;
|
||||
class S{
|
||||
static void Main(){
|
||||
Console.WriteLine("M5RCode C# Block Loaded.");
|
||||
// Add logic for C# if needed for server comm or UI
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?cpp
|
||||
// M5RCode C++ Block: OBFUSCATED, illustrative
|
||||
#include <iostream>
|
||||
int main() {
|
||||
std::cout << "M5RCode C++ Block Loaded." << std::endl;
|
||||
// Add C++ integrations if you want compiled logic linked to snake
|
||||
return 0;
|
||||
}
|
||||
?>
|
||||
111
files/test.m5r
Normal file
111
files/test.m5r
Normal file
@@ -0,0 +1,111 @@
|
||||
<?py
|
||||
# M5RCode Python Block: OBFUSCATED - True 3D Floating Cube & Hello World
|
||||
|
||||
import tkinter as _tk
|
||||
import math as _m
|
||||
|
||||
_WW=700
|
||||
_WH=400
|
||||
|
||||
class _3D:
|
||||
def __init__(self):
|
||||
self._rt=_tk.Tk()
|
||||
self._rt.title(''.join([chr(c) for c in [84,104,114,101,101,68,32,84,101,115,116]])) # ThreeD Test
|
||||
self._cv=_tk.Canvas(self._rt,width=_WW,height=_WH,bg='#181c22',highlightthickness=0)
|
||||
self._cv.pack()
|
||||
self._A=0.0
|
||||
self._B=0.0
|
||||
self._t=0.0
|
||||
self._run()
|
||||
self._rt.mainloop()
|
||||
|
||||
def _pr(self, x,y,z):
|
||||
# Perspective projection
|
||||
d = 400
|
||||
zz = z+220
|
||||
return (
|
||||
_WW//2 + int(d * x / (zz+1)),
|
||||
_WH//2 + int(d * y / (zz+1))
|
||||
)
|
||||
|
||||
def _run(self):
|
||||
self._cv.delete('all')
|
||||
# "3D" hello
|
||||
_s = ''.join([chr(c) for c in [72,101,108,108,111,32,119,111,114,108,100]])
|
||||
for _i in range(17,0,-3):
|
||||
self._cv.create_text(_WW//2+_i,_WH//4+_i,fill=f"#3e238{9-_i//3}",font=('Consolas',62,'bold'),text=_s)
|
||||
self._cv.create_text(_WW//2,_WH//4,fill="#ffe257",font=('Consolas',62,'bold'),text=_s)
|
||||
|
||||
# Draw ground
|
||||
self._cv.create_oval(_WW//2-180,_WH//2+112,_WW//2+185,_WH//2+145,fill="#5800aa",outline="#380075")
|
||||
|
||||
# Cube vertices (3D)
|
||||
_sz=75
|
||||
_F=_m.sin(self._t)*45
|
||||
_verts=[ # 8 points of a cube
|
||||
[-1,-1,-1], [1,-1,-1], [1,1,-1], [-1,1,-1],
|
||||
[-1,-1,1], [1,-1,1], [1,1,1], [-1,1,1]
|
||||
]
|
||||
# 3D rotation and translation
|
||||
_P=[]
|
||||
for v in _verts:
|
||||
x,y,z=v
|
||||
# rotate around Y (self._A), X(self._B)
|
||||
x2=x*_m.cos(self._A)-z*_m.sin(self._A)
|
||||
z2=x*_m.sin(self._A)+z*_m.cos(self._A)
|
||||
y2=y*_m.cos(self._B)-z2*_m.sin(self._B)
|
||||
z3=y*_m.sin(self._B)+z2*_m.cos(self._B)
|
||||
_P.append(self._pr(x2*_sz, y2*_sz+_F, z3*_sz+110))
|
||||
# Cube edges
|
||||
_edges=[(0,1),(1,2),(2,3),(3,0),(4,5),(5,6),(6,7),(7,4),
|
||||
(0,4),(1,5),(2,6),(3,7)]
|
||||
# Draw cube faces (as filled polygons for 3D solid look)
|
||||
_faces=[(0,1,2,3),(4,5,6,7),(0,1,5,4),(2,3,7,6),(0,3,7,4),(1,2,6,5)]
|
||||
_colf=["#66ffee","#f2a2fa","#00eedc","#39dabf","#bfeaff","#ccfcfc"]
|
||||
for ii,f in enumerate(_faces):
|
||||
pts=[_P[i] for i in f]
|
||||
self._cv.create_polygon(pts,fill=_colf[ii],outline="#3c3c57",width=2,stipple='gray25')
|
||||
# Draw all edges (to make it look "wireframe-3d")
|
||||
for a,b in _edges:
|
||||
self._cv.create_line(*_P[a],*_P[b],fill="#231f39",width=3)
|
||||
self._cv.create_line(*_P[a],*_P[b],fill="#aff",width=1)
|
||||
# Animate
|
||||
self._A+=0.09
|
||||
self._B+=0.055
|
||||
self._t+=0.07
|
||||
self._rt.after(24,self._run)
|
||||
|
||||
_3D()
|
||||
?>
|
||||
<?js
|
||||
(function(){
|
||||
var x=[72,101,108,108,111,32,119,111,114,108,100];
|
||||
var s='';
|
||||
for(var i of x){ s+=String.fromCharCode(i); }
|
||||
console.log(s);
|
||||
})();
|
||||
?>
|
||||
<?php
|
||||
${a}=array(72,101,108,108,111,32,119,111,114,108,100);
|
||||
echo implode(array_map('chr',${a})) . "\n";
|
||||
?>
|
||||
<?cs
|
||||
using System;
|
||||
class S{
|
||||
static void Main(){
|
||||
Console.WriteLine(string.Join("", new int[] {72,101,108,108,111,32,119,111,114,108,100}.Select(c => (char)c)));
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?cpp
|
||||
#include <iostream>
|
||||
int main() {
|
||||
int arr[] = {72,101,108,108,111,32,119,111,114,108,100};
|
||||
for(int i = 0; i < 11; i++) std::cout << (char)arr[i];
|
||||
std::cout << std::endl;
|
||||
return 0;
|
||||
}
|
||||
?>
|
||||
<?css
|
||||
body { color: #ffe257; background: #181c22; }
|
||||
?>
|
||||
1
files/testing.m5r
Normal file
1
files/testing.m5r
Normal file
@@ -0,0 +1 @@
|
||||
// New m5r file
|
||||
1
files/testing.pyjs.m5r
Normal file
1
files/testing.pyjs.m5r
Normal file
@@ -0,0 +1 @@
|
||||
// New m5r file
|
||||
Reference in New Issue
Block a user