python """ هذا السكربت ينشئ مشروع تطبيق أندرويد للعبة مكعبات ثلاثية الأبعاد، مع البناء والتكسير والاستكشاف والتحكم باللمس والمخزون والصناعة والحفظ. يتضمن أيضًا البقاء والصحة والجوع والسباحة والليل والنهار وأعداءً مبسطين ووضع البناء الحر؛ لكنه ليس نسخة ماينكرافت بكل محتوياتها، ولا يشمل اللعب الجماعي أو الريدستون أو ا...
نشر بواسطةتم إنشاء الصور باستخدام GPT Image 2
إجابة البحث

Create a landscape editorial hero image for this Studio Global article: Selected skill instructions for this user request: 1. اريد منك دائما التحدث عبر كود يعني ان تتجدث عبر صندوق الكود وليس عبر الدردش 2. اجب على. Article summary: ```python """ هذا السكربت ينشئ مشروع تطبيق أندرويد للعبة مكعبات ثلاثية الأبعاد، مع البناء والتكسير والاستكشاف والتحكم باللمس والمخزون والصناعة والحفظ.. Topic tags: deepresearch, general web, code, python, api. Style: premium digital editorial illustration, source-backed research mood, clean composition, high detail, modern web publication hero. Use reference image context only for broad subject, composition, and topical grounding; do not copy the exact image. Avoid: logos, brand marks, copyrighted characters, real person likenesses, fake screenshots, UI text, readable text, watermarks, charts with fake numbers, clickbait thumbnails, icons, and tiny thumbnail la
"""
هذا السكربت ينشئ مشروع تطبيق أندرويد للعبة مكعبات ثلاثية الأبعاد، مع البناء والتكسير والاستكشاف والتحكم باللمس والمخزون والصناعة والحفظ.
يتضمن أيضًا البقاء والصحة والجوع والسباحة والليل والنهار وأعداءً مبسطين ووضع البناء الحر؛ لكنه ليس نسخة ماينكرافت بكل محتوياتها، ولا يشمل اللعب الجماعي أو الريدستون أو الأبعاد الأخرى.
الناتج كود مشروع يُبنى إلى APK، وليس ملف APK مرفقًا أو إصدارًا اختُبر على هاتف فعلي.
الافتراض: اللعب فردي دون إنترنت، وتجهيز التطبيق على كمبيوتر.
الاستخدام:
1. احفظ هذا الملف باسم create_voxel_android.py
2. شغّله: python create_voxel_android.py
3. اتبع تعليمات BUILD_AR.md داخل المجلد الناتج.
"""
from pathlib import Path
# إعداد AGP 8.7 يدعم compileSdk 35 ويتطلب Gradle 8.9 على الأقل. [4]
# استخدم JDK 17؛ بدأ اشتراطه لتشغيل إضافة أندرويد مع AGP 8.0. [3]
ROOT = Path("VoxelPocket")
if ROOT.exists():
raise SystemExit(
"المجلد VoxelPocket موجود. غيّر اسمه أو انقل السكربت إلى مجلد آخر "
"لتجنب الكتابة فوق ملفاتك."
)
FILES = {
"settings.gradle": r'''
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "VoxelPocket"
include(":app")
''',
"build.gradle": r'''
plugins {
id 'com.android.application' version '8.7.3' apply false
}
''',
"gradle.properties": r'''
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=false
''',
".gitignore": r'''
.gradle/
.idea/
local.properties
**/build/
*.iml
''',
"app/build.gradle": r'''
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.voxelpocket'
compileSdk 35
defaultConfig {
applicationId 'com.example.voxelpocket'
minSdk 23
targetSdk 35
versionCode 1
versionName "0.1"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildTypes {
release {
minifyEnabled false
}
}
}
''',
"app/src/main/AndroidManifest.xml": r'''
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="false"
android:label="عالم المكعبات"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.NoActionBar">
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
'''.lstrip(),
"app/src/main/java/com/example/voxelpocket/MainActivity.java": r'''
package com.example.voxelpocket;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import android.os.Bundle;
import android.util.AtomicFile;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.Random;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import static android.opengl.GLES20.*;
public final class MainActivity extends Activity {
private GLSurfaceView surface;
private Game game;
private Hud hud;
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
);
game = new Game(this);
surface = new GLSurfaceView(this);
surface.setEGLContextClientVersion(2);
surface.setPreserveEGLContextOnPause(true);
surface.setRenderer(game);
surface.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
hud = new Hud(this);
FrameLayout root = new FrameLayout(this);
root.addView(surface);
root.addView(hud);
setContentView(root);
immersive();
}
private void immersive() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
);
}
@Override
public void onWindowFocusChanged(boolean focused) {
super.onWindowFocusChanged(focused);
if (focused) immersive();
}
@Override
protected void onResume() {
super.onResume();
if (surface != null) surface.onResume();
}
@Override
protected void onPause() {
if (hud != null) hud.releaseControls();
if (game != null) game.save();
if (surface != null) surface.onPause();
super.onPause();
}
private void command(Runnable action) {
surface.queueEvent(action);
}
private void showCrafting() {
hud.releaseControls();
command(() -> game.paused = true);
LinearLayout column = new LinearLayout(this);
column.setOrientation(LinearLayout.VERTICAL);
int pad = (int) (16 * getResources().getDisplayMetrics().density);
column.setPadding(pad, pad, pad, pad);
TextView inventory = new TextView(this);
inventory.setText(game.inventoryText);
inventory.setTextSize(16);
column.addView(inventory);
ScrollView scroll = new ScrollView(this);
scroll.addView(column);
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("المخزون والصناعة")
.setView(scroll)
.setNegativeButton("إغلاق", null)
.create();
String[] recipes = {
"ألواح ×4 ← خشب ×1",
"عصي ×4 ← ألواح ×2",
"معول خشبي ← ألواح ×3 + عصي ×2",
"معول حجري ← حجر ×3 + عصي ×2",
"سيف حجري ← حجر ×2 + عصا ×1",
"طوب ×4 ← حجر ×4",
"معول حديدي ← خام حديد ×3 + عصي ×2",
"سيف حديدي ← خام حديد ×2 + عصا ×1"
};
for (int i = 0; i < recipes.length; i++) {
final int recipe = i;
Button button = new Button(this);
button.setText(recipes[i]);
button.setOnClickListener(v -> {
command(() -> game.craft(recipe));
dialog.dismiss();
});
column.addView(button);
}
dialog.setOnDismissListener(d -> {
command(() -> game.paused = false);
immersive();
});
dialog.show();
}
private final class Hud extends View {
private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private int moveId = -1;
private int lookId = -1;
private int mineId = -1;
private int jumpId = -1;
private float lastLookX;
private float lastLookY;
private float stickX;
private float stickY;
Hud(Context context) {
super(context);
setFocusable(true);
}
private void text(Canvas c, String value, float x, float y,
float size, int color) {
paint.setStyle(Paint.Style.FILL);
paint.setColor(color);
paint.setTextSize(size);
paint.setTextAlign(Paint.Align.CENTER);
c.drawText(value, x, y, paint);
}
private void box(Canvas c, float l, float t, float r, float b,
String label, boolean selected) {
RectF rect = new RectF(l, t, r, b);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.argb(175, 18, 24, 35));
c.drawRoundRect(rect, 9, 9, paint);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(selected ? 3 : 1);
paint.setColor(selected ? Color.YELLOW : 0xffb6c5dc);
c.drawRoundRect(rect, 9, 9, paint);
paint.setStyle(Paint.Style.FILL);
text(c, label, (l + r) / 2, (t + b) / 2 + 5,
15, Color.WHITE);
}
private void circle(Canvas c, float x, float y, float radius,
String label) {
paint.setColor(Color.argb(150, 20, 28, 40));
paint.setStyle(Paint.Style.FILL);
c.drawCircle(x, y, radius, paint);
paint.setColor(0xffd2dcef);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
c.drawCircle(x, y, radius, paint);
paint.setStyle(Paint.Style.FILL);
text(c, label, x, y + 6, 18, Color.WHITE);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.scale(getWidth() / 960f, getHeight() / 540f);
paint.setColor(Color.argb(145, 0, 0, 0));
paint.setStyle(Paint.Style.FILL);
canvas.drawRect(0, 0, 960, 49, paint);
text(canvas, game.status, 310, 31, 17, Color.WHITE);
box(canvas, 638, 5, 728, 44, "حفظ", false);
box(canvas, 735, 5, 827, 44, "الوضع", false);
box(canvas, 834, 5, 952, 44, "صناعة", false);
box(canvas, 14, 66, 120, 109, "أكل", false);
text(canvas, game.tip, 490, 84, 17, Color.YELLOW);
paint.setColor(Color.WHITE);
paint.setStrokeWidth(2);
canvas.drawLine(471, 270, 489, 270, paint);
canvas.drawLine(480, 261, 480, 279, paint);
circle(canvas, 100, 400, 67, "");
paint.setColor(0xffb7d8f4);
canvas.drawCircle(
100 + stickX * 42, 400 + stickY * 42, 25, paint
);
text(canvas, "حركة", 100, 502, 17, Color.WHITE);
circle(canvas, 745, 410, 42, "كسر");
circle(canvas, 885, 410, 42, "بناء");
circle(canvas, 815, 300, 38, "قفز");
String[] slots = game.slotText;
for (int i = 0; i < Game.HOTBAR.length; i++) {
float x = 270 + i * 60;
box(canvas, x, 482, x + 57, 536,
slots[i], i == game.selected);
}
text(canvas, "اسحب يمين الشاشة للنظر", 480, 461,
15, 0xffecf2ff);
canvas.restore();
postInvalidateDelayed(66);
}
private boolean insideCircle(float x, float y,
float cx, float cy, float r) {
float dx = x - cx;
float dy = y - cy;
return dx * dx + dy * dy <= r * r;
}
private void updateStick(float x, float y) {
float dx = (x - 100) / 60f;
float dy = (y - 400) / 60f;
float length = (float) Math.sqrt(dx * dx + dy * dy);
if (length > 1) {
dx /= length;
dy /= length;
}
stickX = dx;
stickY = dy;
final float side = dx;
final float forward = -dy;
command(() -> {
game.moveSide = side;
game.moveForward = forward;
});
}
void releaseControls() {
moveId = lookId = mineId = jumpId = -1;
stickX = stickY = 0;
command(() -> {
game.moveSide = 0;
game.moveForward = 0;
game.mining = false;
game.jumpHeld = false;
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (getWidth() == 0 || getHeight() == 0) return true;
int action = event.getActionMasked();
int index = event.getActionIndex();
int id = event.getPointerId(index);
float x = event.getX(index) * 960f / getWidth();
float y = event.getY(index) * 540f / getHeight();
if (action == MotionEvent.ACTION_CANCEL) {
releaseControls();
return true;
}
if (action == MotionEvent.ACTION_DOWN
|| action == MotionEvent.ACTION_POINTER_DOWN) {
if (y < 49 && x >= 834) {
showCrafting();
} else if (y < 49 && x >= 735) {
command(() -> {
game.creative = !game.creative;
game.tip = game.creative
? "بناء حر: موارد غير محدودة ودون ضرر"
: "وضع البقاء";
game.updateHud();
});
} else if (y < 49 && x >= 638) {
command(game::save);
} else if (x < 125 && y >= 60 && y <= 115) {
command(game::eat);
} else if (y >= 482 && x >= 270 && x < 690) {
final int slot = Math.min(6, (int) ((x - 270) / 60));
command(() -> {
game.selected = slot;
game.updateHud();
});
} else if (insideCircle(x, y, 745, 410, 48)
&& mineId == -1) {
mineId = id;
command(() -> {
game.mining = true;
game.mineCooldown = 0;
});
} else if (insideCircle(x, y, 885, 410, 48)) {
command(game::placeBlock);
} else if (insideCircle(x, y, 815, 300, 44)
&& jumpId == -1) {
jumpId = id;
command(() -> game.jumpHeld = true);
} else if (x < 240 && y > 220 && moveId == -1) {
moveId = id;
updateStick(x, y);
} else if (x > 245 && y > 55 && y < 480
&& lookId == -1) {
lookId = id;
lastLookX = x;
lastLookY = y;
}
}
if (action == MotionEvent.ACTION_MOVE) {
for (int i = 0; i < event.getPointerCount(); i++) {
int pointer = event.getPointerId(i);
float px = event.getX(i) * 960f / getWidth();
float py = event.getY(i) * 540f / getHeight();
if (pointer == moveId) updateStick(px, py);
if (pointer == lookId) {
final float dx = px - lastLookX;
final float dy = py - lastLookY;
lastLookX = px;
lastLookY = py;
command(() -> {
game.yaw += dx * 0.004f;
game.pitch = Game.clamp(
game.pitch - dy * 0.004f, -1.48f, 1.48f
);
});
}
}
}
if (action == MotionEvent.ACTION_UP
|| action == MotionEvent.ACTION_POINTER_UP) {
if (id == moveId) {
moveId = -1;
stickX = stickY = 0;
command(() -> {
game.moveSide = 0;
game.moveForward = 0;
});
}
if (id == lookId) lookId = -1;
if (id == mineId) {
mineId = -1;
command(() -> game.mining = false);
}
if (id == jumpId) {
jumpId = -1;
command(() -> game.jumpHeld = false);
}
}
return true;
}
}
private static final class Game implements GLSurfaceView.Renderer {
static final int W = 64;
static final int H = 32;
static final int D = 64;
static final int CHUNK = 8;
static final int SEA = 8;
static final int AIR = 0;
static final int GRASS = 1;
static final int DIRT = 2;
static final int STONE = 3;
static final int WOOD = 4;
static final int LEAVES = 5;
static final int SAND = 6;
static final int PLANK = 7;
static final int BRICK = 8;
static final int BEDROCK = 9;
static final int COAL = 10;
static final int IRON = 11;
static final int WATER = 12;
static final int FOOD = 20;
static final int STICK = 21;
static final int[] HOTBAR = {
DIRT, STONE, WOOD, SAND, PLANK, BRICK, LEAVES
};
static final String[] NAMES = {
"هواء", "عشب", "تراب", "حجر", "خشب", "ورق",
"رمل", "ألواح", "طوب", "صخر", "فحم", "حديد", "ماء"
};
static final float[][] COLORS = {
{0, 0, 0},
{.31f, .70f, .23f},
{.49f, .32f, .18f},
{.55f, .57f, .59f},
{.45f, .27f, .12f},
{.19f, .52f, .20f},
{.83f, .77f, .49f},
{.70f, .49f, .25f},
{.67f, .27f, .20f},
{.17f, .18f, .21f},
{.27f, .29f, .32f},
{.68f, .49f, .37f},
{.13f, .39f, .72f}
};
static final int[][] NORMALS = {
{1, 0, 0}, {-1, 0, 0},
{0, 1, 0}, {0, -1, 0},
{0, 0, 1}, {0, 0, -1}
};
static final float[][][] FACES = {
{{1,0,0},{1,1,0},{1,1,1},{1,0,1}},
{{0,0,1},{0,1,1},{0,1,0},{0,0,0}},
{{0,1,0},{0,1,1},{1,1,1},{1,1,0}},
{{0,0,1},{0,0,0},{1,0,0},{1,0,1}},
{{1,0,1},{1,1,1},{0,1,1},{0,0,1}},
{{0,0,0},{0,1,0},{1,1,0},{1,0,0}}
};
static final int[] TRI = {0, 1, 2, 0, 2, 3};
static final float[] SHADE = {.80f, .66f, 1f, .48f, .87f, .72f};
private final byte[] world = new byte[W * H * D];
private final int[] inventory = new int[32];
private final Chunk[] chunks = new Chunk[(W / CHUNK) * (D / CHUNK)];
private final ArrayList<Mob> mobs = new ArrayList<>();
private final Random random = new Random();
private final AtomicFile saveFile;
private final float[] projection = new float[16];
private final float[] view = new float[16];
private final float[] mvp = new float[16];
private final Mesh actors = new Mesh();
private final Mesh outline = new Mesh();
private int program;
private int positionAttribute;
private int colorAttribute;
private int matrixUniform;
private int eyeUniform;
private int skyUniform;
private int dayUniform;
private long previousFrame;
float px, py, pz;
float yaw, pitch, velocityY;
float moveSide, moveForward;
float health = 20;
float hunger = 20;
float oxygen = 12;
float time = .20f;
float mineCooldown;
float saveClock;
float hudClock;
float survivalClock;
float spawnClock;
float regenerationClock;
int pickaxe;
int sword;
boolean grounded;
boolean mining;
boolean jumpHeld;
boolean paused;
volatile boolean creative;
volatile int selected;
volatile String status = "";
volatile String tip = "اجمع الخشب وافتح الصناعة لصنع معول";
volatile String inventoryText = "";
volatile String[] slotText = {"", "", "", "", "", "", ""};
Game(Context context) {
saveFile = new AtomicFile(
new File(context.getFilesDir(), "world-v1.bin")
);
for (int z = 0; z < D / CHUNK; z++) {
for (int x = 0; x < W / CHUNK; x++) {
chunks[x + z * (W / CHUNK)] = new Chunk(x, z);
}
}
if (!load()) generate();
updateHud();
}
static float clamp(float value, float min, float max) {
return Math.max(min, Math.min(max, value));
}
private static int floor(float value) {
return (int) Math.floor(value);
}
private boolean inBounds(int x, int y, int z) {
return x >= 0 && x < W && y >= 0 && y < H
&& z >= 0 && z < D;
}
private int index(int x, int y, int z) {
return x + W * (z + D * y);
}
private int get(int x, int y, int z) {
if (!inBounds(x, y, z)) return AIR;
return world[index(x, y, z)] & 255;
}
private boolean solid(int block) {
return block != AIR && block != WATER;
}
private void rawSet(int x, int y, int z, int block) {
if (inBounds(x, y, z)) {
world[index(x, y, z)] = (byte) block;
}
}
private void dirtyAt(int x, int z) {
if (x < 0 || z < 0 || x >= W || z >= D) return;
chunks[x / CHUNK + (z / CHUNK) * (W / CHUNK)].dirty = true;
}
private void set(int x, int y, int z, int block) {
if (!inBounds(x, y, z)) return;
rawSet(x, y, z, block);
dirtyAt(x, z);
dirtyAt(x - 1, z);
dirtyAt(x + 1, z);
dirtyAt(x, z - 1);
dirtyAt(x, z + 1);
}
private void generate() {
java.util.Arrays.fill(world, (byte) AIR);
java.util.Arrays.fill(inventory, 0);
mobs.clear();
float offset = random.nextFloat() * 1000;
for (int z = 0; z < D; z++) {
for (int x = 0; x < W; x++) {
int top = 9 + (int) (
Math.sin((x + offset) * .12) * 3
+ Math.cos((z - offset) * .13) * 3
+ Math.sin((x + z) * .07) * 2
);
top = Math.max(4, Math.min(18, top));
if (Math.abs(x - W / 2) < 4
&& Math.abs(z - D / 2) < 4) {
top = Math.max(top, 12);
}
for (int y = 0; y <= top; y++) {
int block;
if (y == 0) {
block = BEDROCK;
} else if (y == top) {
block = top <= SEA + 1 ? SAND : GRASS;
} else if (y >= top - 2) {
block = DIRT;
} else {
block = STONE;
double c
Studio Global AI
تتضمن هذه الصفحة إجابة مدعومة بالمصدر يمكنك المتابعة داخل Studio Global.
```python """ هذا السكربت ينشئ مشروع تطبيق أندرويد للعبة مكعبات ثلاثية الأبعاد، مع البناء والتكسير والاستكشاف والتحكم باللمس والمخزون والصناعة والحفظ.
```python """ هذا السكربت ينشئ مشروع تطبيق أندرويد للعبة مكعبات ثلاثية الأبعاد، مع البناء والتكسير والاستكشاف والتحكم باللمس والمخزون والصناعة والحفظ. يتضمن أيضًا البقاء والصحة والجوع والسباحة والليل والنهار وأعداءً مبسطين ووضع البناء الحر؛ لكنه ليس نسخة ماينكرافت بكل محتوياتها، ولا يشمل اللعب الجماعي أو الريدستون أو الأبعاد الأخرى.
الناتج كود مشروع يُبنى إلى APK، وليس ملف APK مرفقًا أو إصدارًا اختُبر على هاتف فعلي.