diff --git a/Занимательное программирование/2/1_horizontal_scroll/.gitignore b/Занимательное программирование/2/1_horizontal_scroll/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/1_horizontal_scroll/assets/background.bmp b/Занимательное программирование/2/1_horizontal_scroll/assets/background.bmp new file mode 100644 index 0000000..294ffa0 Binary files /dev/null and b/Занимательное программирование/2/1_horizontal_scroll/assets/background.bmp differ diff --git a/Занимательное программирование/2/1_horizontal_scroll/assets/background2.bmp b/Занимательное программирование/2/1_horizontal_scroll/assets/background2.bmp new file mode 100644 index 0000000..75a250c Binary files /dev/null and b/Занимательное программирование/2/1_horizontal_scroll/assets/background2.bmp differ diff --git a/Занимательное программирование/2/1_horizontal_scroll/assets/badlogic.jpg b/Занимательное программирование/2/1_horizontal_scroll/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/Занимательное программирование/2/1_horizontal_scroll/assets/badlogic.jpg differ diff --git a/Занимательное программирование/2/1_horizontal_scroll/assets/bucket.png b/Занимательное программирование/2/1_horizontal_scroll/assets/bucket.png new file mode 100644 index 0000000..0538dc3 Binary files /dev/null and b/Занимательное программирование/2/1_horizontal_scroll/assets/bucket.png differ diff --git a/Занимательное программирование/2/1_horizontal_scroll/assets/drop.png b/Занимательное программирование/2/1_horizontal_scroll/assets/drop.png new file mode 100644 index 0000000..8ce41f4 Binary files /dev/null and b/Занимательное программирование/2/1_horizontal_scroll/assets/drop.png differ diff --git a/Занимательное программирование/2/1_horizontal_scroll/build.gradle b/Занимательное программирование/2/1_horizontal_scroll/build.gradle new file mode 100644 index 0000000..370900c --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/build.gradle @@ -0,0 +1,57 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Modelling" + gdxVersion = '1.13.5' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} diff --git a/Занимательное программирование/2/1_horizontal_scroll/core/build.gradle b/Занимательное программирование/2/1_horizontal_scroll/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/1_horizontal_scroll/core/src/net/caraus/modelling/Modelling.java b/Занимательное программирование/2/1_horizontal_scroll/core/src/net/caraus/modelling/Modelling.java new file mode 100644 index 0000000..d2ad2d1 --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/core/src/net/caraus/modelling/Modelling.java @@ -0,0 +1,74 @@ +package net.caraus.modelling; + +import java.util.Iterator; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.ScreenUtils; +import com.badlogic.gdx.math.Rectangle; + +public class Modelling extends ApplicationAdapter { + private OrthographicCamera camera; + private SpriteBatch batch; + private Array backgrounds; + private Texture backgroundImage; + + static final int SCREEN_WIDTH = 609; + static final int SCREEN_HEIGHT = 456; + static final int STEP = 100; + + @Override + public void create () { + backgroundImage = new Texture(Gdx.files.internal("background.bmp")); + + camera = new OrthographicCamera(); + camera.setToOrtho(false, SCREEN_WIDTH, SCREEN_HEIGHT); + + batch = new SpriteBatch(); + backgrounds = new Array(); + + Rectangle nextRectangle = new Rectangle(); + nextRectangle.x = -SCREEN_WIDTH; + nextRectangle.y = 0; + backgrounds.add(nextRectangle); + + nextRectangle = new Rectangle(); + nextRectangle.x = 0; + nextRectangle.y = 0; + backgrounds.add(nextRectangle); + } + + @Override + public void render () { + ScreenUtils.clear(0, 0, 0.2f, 1); + + camera.update(); + batch.setProjectionMatrix(camera.combined); + + backgrounds.get(0).x = backgrounds.get(0).x + STEP * Gdx.graphics.getDeltaTime(); + backgrounds.get(1).x = backgrounds.get(1).x + STEP * Gdx.graphics.getDeltaTime(); + + if (backgrounds.get(0).x >= 0) { + for (Iterator iter = backgrounds.iterator(); iter.hasNext(); ) { + Rectangle background = iter.next(); + + background.x = background.x - SCREEN_WIDTH; + } + } + batch.begin(); + for (Rectangle background: backgrounds) { + batch.draw(backgroundImage, background.x, background.y); + } + batch.end(); + } + + @Override + public void dispose () { + backgroundImage.dispose(); + batch.dispose(); + } +} diff --git a/Занимательное программирование/2/1_horizontal_scroll/desktop/build.gradle b/Занимательное программирование/2/1_horizontal_scroll/desktop/build.gradle new file mode 100644 index 0000000..89712af --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.modelling.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/1_horizontal_scroll/desktop/src/net/caraus/modelling/DesktopLauncher.java b/Занимательное программирование/2/1_horizontal_scroll/desktop/src/net/caraus/modelling/DesktopLauncher.java new file mode 100644 index 0000000..757aed8 --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/desktop/src/net/caraus/modelling/DesktopLauncher.java @@ -0,0 +1,19 @@ +package net.caraus.modelling; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import net.caraus.modelling.Modelling; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + + config.setTitle("Drop"); + config.setWindowedMode(800, 480); + config.useVsync(true); + config.setForegroundFPS(60); + + new Lwjgl3Application(new Modelling(), config); + } +} diff --git a/Занимательное программирование/2/1_horizontal_scroll/gradle.properties b/Занимательное программирование/2/1_horizontal_scroll/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/1_horizontal_scroll/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/1_horizontal_scroll/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/1_horizontal_scroll/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/1_horizontal_scroll/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/1_horizontal_scroll/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/1_horizontal_scroll/gradlew b/Занимательное программирование/2/1_horizontal_scroll/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/1_horizontal_scroll/gradlew.bat b/Занимательное программирование/2/1_horizontal_scroll/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/1_horizontal_scroll/settings.gradle b/Занимательное программирование/2/1_horizontal_scroll/settings.gradle new file mode 100644 index 0000000..74fc652 --- /dev/null +++ b/Занимательное программирование/2/1_horizontal_scroll/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'core' \ No newline at end of file diff --git a/Занимательное программирование/2/2_vertical_scroll/.gitignore b/Занимательное программирование/2/2_vertical_scroll/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/2_vertical_scroll/assets/background.bmp b/Занимательное программирование/2/2_vertical_scroll/assets/background.bmp new file mode 100644 index 0000000..294ffa0 Binary files /dev/null and b/Занимательное программирование/2/2_vertical_scroll/assets/background.bmp differ diff --git a/Занимательное программирование/2/2_vertical_scroll/assets/background2.bmp b/Занимательное программирование/2/2_vertical_scroll/assets/background2.bmp new file mode 100644 index 0000000..75a250c Binary files /dev/null and b/Занимательное программирование/2/2_vertical_scroll/assets/background2.bmp differ diff --git a/Занимательное программирование/2/2_vertical_scroll/assets/badlogic.jpg b/Занимательное программирование/2/2_vertical_scroll/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/Занимательное программирование/2/2_vertical_scroll/assets/badlogic.jpg differ diff --git a/Занимательное программирование/2/2_vertical_scroll/assets/bucket.png b/Занимательное программирование/2/2_vertical_scroll/assets/bucket.png new file mode 100644 index 0000000..0538dc3 Binary files /dev/null and b/Занимательное программирование/2/2_vertical_scroll/assets/bucket.png differ diff --git a/Занимательное программирование/2/2_vertical_scroll/assets/drop.png b/Занимательное программирование/2/2_vertical_scroll/assets/drop.png new file mode 100644 index 0000000..8ce41f4 Binary files /dev/null and b/Занимательное программирование/2/2_vertical_scroll/assets/drop.png differ diff --git a/Занимательное программирование/2/2_vertical_scroll/build.gradle b/Занимательное программирование/2/2_vertical_scroll/build.gradle new file mode 100644 index 0000000..370900c --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/build.gradle @@ -0,0 +1,57 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Modelling" + gdxVersion = '1.13.5' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/core/build.gradle b/Занимательное программирование/2/2_vertical_scroll/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/DiagonalScreen.java b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/DiagonalScreen.java new file mode 100644 index 0000000..5828ce0 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/DiagonalScreen.java @@ -0,0 +1,81 @@ +package net.caraus.modelling; + +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.utils.ScreenUtils; +import com.badlogic.gdx.math.Rectangle; + +public class DiagonalScreen extends GameScreen { + + public DiagonalScreen(final Modelling game) { + super(game); + + Rectangle nextRectangle = new Rectangle(); + nextRectangle.x = -SCREEN_WIDTH; + nextRectangle.y = 0; + backgrounds.add(nextRectangle); + + nextRectangle = new Rectangle(); + nextRectangle.x = 0; + nextRectangle.y = -SCREEN_HEIGHT; + backgrounds.add(nextRectangle); + + nextRectangle = new Rectangle(); + nextRectangle.x = -SCREEN_WIDTH; + nextRectangle.y = -SCREEN_HEIGHT; + backgrounds.add(nextRectangle); + + nextRectangle = new Rectangle(); + nextRectangle.x = 0; + nextRectangle.y = 0; + backgrounds.add(nextRectangle); + } + + @Override + public void render(float delta) { + ScreenUtils.clear(0, 0, 0.2f, 1); + + camera.update(); + batch.setProjectionMatrix(camera.combined); + + float xStep = SCREEN_WIDTH / 10; + float yStep = SCREEN_HEIGHT / 10; + + backgrounds.get(0).x = backgrounds.get(0).x + xStep * delta; + backgrounds.get(1).x = backgrounds.get(1).x + xStep * delta; + backgrounds.get(2).x = backgrounds.get(2).x + xStep * delta; + backgrounds.get(3).x = backgrounds.get(3).x + xStep * delta; + + backgrounds.get(0).y = backgrounds.get(0).y + yStep * delta; + backgrounds.get(1).y = backgrounds.get(1).y + yStep * delta; + backgrounds.get(2).y = backgrounds.get(2).y + yStep * delta; + backgrounds.get(3).y = backgrounds.get(3).y + yStep * delta; + + if (backgrounds.get(0).x >= 0) { + for (Iterator iter = backgrounds.iterator(); iter.hasNext(); ) { + Rectangle background = iter.next(); + + background.x = background.x - SCREEN_WIDTH; + } + } + if (backgrounds.get(1).y >= 0) { + for (Iterator iter = backgrounds.iterator(); iter.hasNext(); ) { + Rectangle background = iter.next(); + + background.y = background.y - SCREEN_HEIGHT; + } + } + batch.begin(); + for (Rectangle background: backgrounds) { + batch.draw(backgroundImage, background.x, background.y); + } + batch.end(); + + if (Gdx.input.isKeyPressed(Keys.ESCAPE)) { + game.setScreen(new MainMenuScreen(game)); + dispose(); + } + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/GameScreen.java b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/GameScreen.java new file mode 100644 index 0000000..c739459 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/GameScreen.java @@ -0,0 +1,59 @@ +package net.caraus.modelling; + +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.math.Rectangle; + +public abstract class GameScreen implements Screen { + protected final Modelling game; + + protected OrthographicCamera camera; + protected SpriteBatch batch; + protected Array backgrounds; + protected Texture backgroundImage; + + static final int SCREEN_WIDTH = 609; + static final int SCREEN_HEIGHT = 456; + static final int STEP = 100; + + public GameScreen(final Modelling game) { + this.game = game; + backgroundImage = new Texture(Gdx.files.internal("background.bmp")); + + camera = new OrthographicCamera(); + camera.setToOrtho(false, SCREEN_WIDTH, SCREEN_HEIGHT); + + batch = new SpriteBatch(); + backgrounds = new Array(); + } + + @Override + public void resize(int width, int height) { + } + + @Override + public void show() { + } + + @Override + public void hide() { + } + + @Override + public void pause() { + } + + @Override + public void resume() { + } + + @Override + public void dispose () { + backgroundImage.dispose(); + batch.dispose(); + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/HorizontalScreen.java b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/HorizontalScreen.java new file mode 100644 index 0000000..9d35c78 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/HorizontalScreen.java @@ -0,0 +1,54 @@ +package net.caraus.modelling; + +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.utils.ScreenUtils; +import com.badlogic.gdx.math.Rectangle; + +public class HorizontalScreen extends GameScreen { + + public HorizontalScreen(final Modelling game) { + super(game); + + Rectangle nextRectangle = new Rectangle(); + nextRectangle.x = -SCREEN_WIDTH; + nextRectangle.y = 0; + backgrounds.add(nextRectangle); + + nextRectangle = new Rectangle(); + nextRectangle.x = 0; + nextRectangle.y = 0; + backgrounds.add(nextRectangle); + } + + @Override + public void render(float delta) { + ScreenUtils.clear(0, 0, 0.2f, 1); + + camera.update(); + batch.setProjectionMatrix(camera.combined); + + backgrounds.get(0).x = backgrounds.get(0).x + STEP * Gdx.graphics.getDeltaTime(); + backgrounds.get(1).x = backgrounds.get(1).x + STEP * Gdx.graphics.getDeltaTime(); + + if (backgrounds.get(0).x >= 0) { + for (Iterator iter = backgrounds.iterator(); iter.hasNext(); ) { + Rectangle background = iter.next(); + + background.x = background.x - SCREEN_WIDTH; + } + } + batch.begin(); + for (Rectangle background: backgrounds) { + batch.draw(backgroundImage, background.x, background.y); + } + batch.end(); + + if (Gdx.input.isKeyPressed(Keys.ESCAPE)) { + game.setScreen(new MainMenuScreen(game)); + dispose(); + } + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/MainMenuScreen.java b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/MainMenuScreen.java new file mode 100644 index 0000000..56136c1 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/MainMenuScreen.java @@ -0,0 +1,117 @@ +package net.caraus.modelling; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle; +import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; +import com.badlogic.gdx.utils.ScreenUtils; +import com.badlogic.gdx.graphics.g2d.BitmapFont; + +public class MainMenuScreen implements Screen { + final Modelling game; + + BitmapFont font; + OrthographicCamera camera; + + private TextButton horizontalButton; + private TextButton verticalButton; + private TextButton crossButton; + + private Stage stage; + private Table table; + + public MainMenuScreen(final Modelling game) { + this.game = game; + + font = new BitmapFont(); // use libGDX's default Arial font. + camera = new OrthographicCamera(); + camera.setToOrtho(false, 800, 480); + + stage = new Stage(); + Gdx.input.setInputProcessor(stage); + + table = new Table(); + table.setFillParent(true); + table.setDebug(true); + stage.addActor(table); + + createButtons(); + } + + private void createButtons() { + TextButtonStyle style = new TextButtonStyle(); + style.font = font; + + table.row().width(150); + + horizontalButton = new TextButton("Waagerecht", style); + horizontalButton.addListener(new ChangeListener() { + public void changed(ChangeEvent event, Actor actor) { + game.setScreen(new HorizontalScreen(game)); + dispose(); + } + }); + table.add(horizontalButton); + + verticalButton = new TextButton("Senkrecht", style); + verticalButton.addListener(new ChangeListener() { + public void changed(ChangeEvent event, Actor actor) { + game.setScreen(new VerticalScreen(game)); + dispose(); + } + }); + table.add(verticalButton); + + crossButton = new TextButton("Diagonal", style); + crossButton.addListener(new ChangeListener() { + public void changed(ChangeEvent event, Actor actor) { + game.setScreen(new DiagonalScreen(game)); + dispose(); + } + }); + table.add(crossButton); + } + + @Override + public void render(float delta) { + ScreenUtils.clear(0, 0, 0.2f, 1); + + camera.update(); + game.batch.setProjectionMatrix(camera.combined); + + stage.act(delta); + stage.draw(); + } + + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + } + + @Override + public void show() { + } + + @Override + public void hide() { + } + + @Override + public void pause() { + } + + @Override + public void resume() { + } + + @Override + public void dispose() { + stage.dispose(); + font.dispose(); + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/Modelling.java b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/Modelling.java new file mode 100644 index 0000000..5949186 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/Modelling.java @@ -0,0 +1,21 @@ +package net.caraus.modelling; + +import com.badlogic.gdx.Game; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +public class Modelling extends Game { + public SpriteBatch batch; + + public void create() { + batch = new SpriteBatch(); + this.setScreen(new MainMenuScreen(this)); + } + + public void render() { + super.render(); + } + + public void dispose() { + batch.dispose(); + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/VerticalScreen.java b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/VerticalScreen.java new file mode 100644 index 0000000..2e56977 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/core/src/net/caraus/modelling/VerticalScreen.java @@ -0,0 +1,54 @@ +package net.caraus.modelling; + +import java.util.Iterator; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.utils.ScreenUtils; +import com.badlogic.gdx.math.Rectangle; + +public class VerticalScreen extends GameScreen { + + public VerticalScreen(final Modelling game) { + super(game); + + Rectangle nextRectangle = new Rectangle(); + nextRectangle.x = 0; + nextRectangle.y = -SCREEN_HEIGHT; + backgrounds.add(nextRectangle); + + nextRectangle = new Rectangle(); + nextRectangle.x = 0; + nextRectangle.y = 0; + backgrounds.add(nextRectangle); + } + + @Override + public void render(float delta) { + ScreenUtils.clear(0, 0, 0.2f, 1); + + camera.update(); + batch.setProjectionMatrix(camera.combined); + + backgrounds.get(0).y = backgrounds.get(0).y + STEP * Gdx.graphics.getDeltaTime(); + backgrounds.get(1).y = backgrounds.get(1).y + STEP * Gdx.graphics.getDeltaTime(); + + if (backgrounds.get(0).y >= 0) { + for (Iterator iter = backgrounds.iterator(); iter.hasNext(); ) { + Rectangle background = iter.next(); + + background.y = background.y - SCREEN_HEIGHT; + } + } + batch.begin(); + for (Rectangle background: backgrounds) { + batch.draw(backgroundImage, background.x, background.y); + } + batch.end(); + + if (Gdx.input.isKeyPressed(Keys.ESCAPE)) { + game.setScreen(new MainMenuScreen(game)); + dispose(); + } + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/desktop/build.gradle b/Занимательное программирование/2/2_vertical_scroll/desktop/build.gradle new file mode 100644 index 0000000..89712af --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.modelling.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/2_vertical_scroll/desktop/src/net/caraus/modelling/DesktopLauncher.java b/Занимательное программирование/2/2_vertical_scroll/desktop/src/net/caraus/modelling/DesktopLauncher.java new file mode 100644 index 0000000..757aed8 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/desktop/src/net/caraus/modelling/DesktopLauncher.java @@ -0,0 +1,19 @@ +package net.caraus.modelling; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import net.caraus.modelling.Modelling; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + + config.setTitle("Drop"); + config.setWindowedMode(800, 480); + config.useVsync(true); + config.setForegroundFPS(60); + + new Lwjgl3Application(new Modelling(), config); + } +} diff --git a/Занимательное программирование/2/2_vertical_scroll/gradle.properties b/Занимательное программирование/2/2_vertical_scroll/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/2_vertical_scroll/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/2_vertical_scroll/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/2_vertical_scroll/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/2_vertical_scroll/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/2_vertical_scroll/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/2_vertical_scroll/gradlew b/Занимательное программирование/2/2_vertical_scroll/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/2_vertical_scroll/gradlew.bat b/Занимательное программирование/2/2_vertical_scroll/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/2_vertical_scroll/settings.gradle b/Занимательное программирование/2/2_vertical_scroll/settings.gradle new file mode 100644 index 0000000..74fc652 --- /dev/null +++ b/Занимательное программирование/2/2_vertical_scroll/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'core' \ No newline at end of file diff --git a/Занимательное программирование/2/3_multi_layer/.gitignore b/Занимательное программирование/2/3_multi_layer/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/3_multi_layer/assets/clouds.jpg b/Занимательное программирование/2/3_multi_layer/assets/clouds.jpg new file mode 100644 index 0000000..9447892 Binary files /dev/null and b/Занимательное программирование/2/3_multi_layer/assets/clouds.jpg differ diff --git a/Занимательное программирование/2/3_multi_layer/assets/ground.jpg b/Занимательное программирование/2/3_multi_layer/assets/ground.jpg new file mode 100644 index 0000000..ed6f93b Binary files /dev/null and b/Занимательное программирование/2/3_multi_layer/assets/ground.jpg differ diff --git a/Занимательное программирование/2/3_multi_layer/assets/tree.png b/Занимательное программирование/2/3_multi_layer/assets/tree.png new file mode 100644 index 0000000..51941fb Binary files /dev/null and b/Занимательное программирование/2/3_multi_layer/assets/tree.png differ diff --git a/Занимательное программирование/2/3_multi_layer/build.gradle b/Занимательное программирование/2/3_multi_layer/build.gradle new file mode 100644 index 0000000..bd94064 --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/build.gradle @@ -0,0 +1,57 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Multi Layer Background" + gdxVersion = '1.13.5' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} diff --git a/Занимательное программирование/2/3_multi_layer/core/build.gradle b/Занимательное программирование/2/3_multi_layer/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/3_multi_layer/core/src/net/caraus/multilayer/MultiLayer.java b/Занимательное программирование/2/3_multi_layer/core/src/net/caraus/multilayer/MultiLayer.java new file mode 100644 index 0000000..4cec49b --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/core/src/net/caraus/multilayer/MultiLayer.java @@ -0,0 +1,61 @@ +package net.caraus.multilayer; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.ScreenUtils; + +public class MultiLayer extends ApplicationAdapter { + SpriteBatch batch; + + Texture clouds; + Texture ground; + Texture tree; + + float cloudsPosition = 512.0f; + float groundPosition = 0.0f; + float treePosition = 0.0f; + + boolean reverseDirection = false; + + @Override + public void create () { + batch = new SpriteBatch(); + + clouds = new Texture("clouds.jpg"); + ground = new Texture("ground.jpg"); + tree = new Texture("tree.png"); + } + + @Override + public void render () { + ScreenUtils.clear(0, 0, 0, 1); + batch.begin(); + batch.draw(ground, 0, groundPosition); + batch.draw(clouds, 0, cloudsPosition); + batch.draw(tree, 0, treePosition); + batch.end(); + + if (reverseDirection) { + groundPosition += 3.0f; + cloudsPosition += 1.0f; + treePosition += 4.0f; + } else { + groundPosition -= 3.0f; + cloudsPosition -= 1.0f; + treePosition -= 4.0f; + } + if (cloudsPosition < 360 || cloudsPosition > 512) { + reverseDirection = !reverseDirection; + } + } + + @Override + public void dispose () { + batch.dispose(); + + ground.dispose(); + tree.dispose(); + clouds.dispose(); + } +} diff --git a/Занимательное программирование/2/3_multi_layer/desktop/build.gradle b/Занимательное программирование/2/3_multi_layer/desktop/build.gradle new file mode 100644 index 0000000..900a646 --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.multilayer.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/3_multi_layer/desktop/src/net/caraus/multilayer/DesktopLauncher.java b/Занимательное программирование/2/3_multi_layer/desktop/src/net/caraus/multilayer/DesktopLauncher.java new file mode 100644 index 0000000..bfd1ef3 --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/desktop/src/net/caraus/multilayer/DesktopLauncher.java @@ -0,0 +1,17 @@ +package net.caraus.multilayer; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + + config.setForegroundFPS(60); + config.setTitle("Multi Layer Background"); + config.setWindowedMode(1280, 1024); + + new Lwjgl3Application(new MultiLayer(), config); + } +} diff --git a/Занимательное программирование/2/3_multi_layer/gradle.properties b/Занимательное программирование/2/3_multi_layer/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/3_multi_layer/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/3_multi_layer/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/3_multi_layer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/3_multi_layer/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/3_multi_layer/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/3_multi_layer/gradlew b/Занимательное программирование/2/3_multi_layer/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/3_multi_layer/gradlew.bat b/Занимательное программирование/2/3_multi_layer/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/3_multi_layer/settings.gradle b/Занимательное программирование/2/3_multi_layer/settings.gradle new file mode 100644 index 0000000..74fc652 --- /dev/null +++ b/Занимательное программирование/2/3_multi_layer/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'core' \ No newline at end of file diff --git a/Занимательное программирование/2/4_fading_in/.gitignore b/Занимательное программирование/2/4_fading_in/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/4_fading_in/assets/badlogic.bmp b/Занимательное программирование/2/4_fading_in/assets/badlogic.bmp new file mode 100644 index 0000000..81caec7 Binary files /dev/null and b/Занимательное программирование/2/4_fading_in/assets/badlogic.bmp differ diff --git a/Занимательное программирование/2/4_fading_in/assets/badlogic.jpg b/Занимательное программирование/2/4_fading_in/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/Занимательное программирование/2/4_fading_in/assets/badlogic.jpg differ diff --git a/Занимательное программирование/2/4_fading_in/build.gradle b/Занимательное программирование/2/4_fading_in/build.gradle new file mode 100644 index 0000000..ffa78da --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/build.gradle @@ -0,0 +1,57 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Fade In" + gdxVersion = '1.13.5' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} diff --git a/Занимательное программирование/2/4_fading_in/core/build.gradle b/Занимательное программирование/2/4_fading_in/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/4_fading_in/core/src/net/caraus/fadein/FadeIn.java b/Занимательное программирование/2/4_fading_in/core/src/net/caraus/fadein/FadeIn.java new file mode 100644 index 0000000..bd9b6e1 --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/core/src/net/caraus/fadein/FadeIn.java @@ -0,0 +1,84 @@ +package net.caraus.fadein; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.Pixmap.Format; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.ScreenUtils; + +public class FadeIn extends ApplicationAdapter { + SpriteBatch batch; + + Texture etalonTexture; + Pixmap etalon; + + Pixmap pixmap; + Texture img; + int[][][] buffer; + + @Override + public void create () { + batch = new SpriteBatch(); + + FileHandle fileHandle = Gdx.files.internal("badlogic.bmp"); + etalon = new Pixmap(fileHandle); + etalonTexture = new Texture(etalon); + + pixmap = new Pixmap(etalon.getWidth(), etalon.getHeight(), Format.RGB888); + buffer = new int[etalon.getWidth()][etalon.getHeight()][3]; + for (int i = 0; i < pixmap.getWidth(); ++i) { + for (int j = 0; j < pixmap.getHeight(); ++j) { + buffer[i][j][0] = 0xff; + buffer[i][j][1] = 0xff; + buffer[i][j][2] = 0xff; + } + } + img = new Texture(pixmap); + } + + @Override + public void render () { + ScreenUtils.clear(1, 0, 0, 1); + + for (int i = 0; i < pixmap.getWidth(); ++i) { + for (int j = 0; j < pixmap.getHeight(); ++j) { + int etalonPixel = etalon.getPixel(i, j); + + int etalonRed = (etalonPixel >> 24) & 0xff; + int etalonGreen = (etalonPixel >> 16) & 0xff; + int etalonBlue = (etalonPixel >> 8) & 0xff; + + if (etalonRed < buffer[i][j][0]) { + --buffer[i][j][0]; + } + if (etalonGreen < buffer[i][j][1]) { + --buffer[i][j][1]; + } + if (etalonBlue < buffer[i][j][2]) { + --buffer[i][j][2]; + } + pixmap.setColor((buffer[i][j][0] << 24) | (buffer[i][j][1] << 16) | (buffer[i][j][2] << 8) | 0xff); + pixmap.drawPixel(i, j); + } + } + img.draw(pixmap, 0, 0); + + batch.begin(); + batch.draw(etalonTexture, 0, 0); + batch.draw(img, etalon.getWidth() + 15, 0); + batch.end(); + } + + @Override + public void dispose () { + batch.dispose(); + etalonTexture.dispose(); + etalon.dispose(); + + img.dispose(); + pixmap.dispose(); + } +} diff --git a/Занимательное программирование/2/4_fading_in/desktop/build.gradle b/Занимательное программирование/2/4_fading_in/desktop/build.gradle new file mode 100644 index 0000000..446836b --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.fadein.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/4_fading_in/desktop/src/net/caraus/fadein/DesktopLauncher.java b/Занимательное программирование/2/4_fading_in/desktop/src/net/caraus/fadein/DesktopLauncher.java new file mode 100644 index 0000000..087ba87 --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/desktop/src/net/caraus/fadein/DesktopLauncher.java @@ -0,0 +1,15 @@ +package net.caraus.fadein; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import net.caraus.fadein.FadeIn; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + config.setForegroundFPS(30); + config.setTitle("Fade In"); + new Lwjgl3Application(new FadeIn(), config); + } +} diff --git a/Занимательное программирование/2/4_fading_in/gradle.properties b/Занимательное программирование/2/4_fading_in/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/4_fading_in/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/4_fading_in/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/4_fading_in/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/4_fading_in/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/4_fading_in/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/4_fading_in/gradlew b/Занимательное программирование/2/4_fading_in/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/4_fading_in/gradlew.bat b/Занимательное программирование/2/4_fading_in/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/4_fading_in/settings.gradle b/Занимательное программирование/2/4_fading_in/settings.gradle new file mode 100644 index 0000000..e362338 --- /dev/null +++ b/Занимательное программирование/2/4_fading_in/settings.gradle @@ -0,0 +1 @@ +include 'core', 'desktop' \ No newline at end of file diff --git a/Занимательное программирование/2/5_change_pic/.gitignore b/Занимательное программирование/2/5_change_pic/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/5_change_pic/assets/background2.bmp b/Занимательное программирование/2/5_change_pic/assets/background2.bmp new file mode 100644 index 0000000..9d68dfc Binary files /dev/null and b/Занимательное программирование/2/5_change_pic/assets/background2.bmp differ diff --git a/Занимательное программирование/2/5_change_pic/assets/badlogic.bmp b/Занимательное программирование/2/5_change_pic/assets/badlogic.bmp new file mode 100644 index 0000000..81caec7 Binary files /dev/null and b/Занимательное программирование/2/5_change_pic/assets/badlogic.bmp differ diff --git a/Занимательное программирование/2/5_change_pic/build.gradle b/Занимательное программирование/2/5_change_pic/build.gradle new file mode 100644 index 0000000..81117fb --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/build.gradle @@ -0,0 +1,57 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Fade In" + gdxVersion = '1.11.0' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} diff --git a/Занимательное программирование/2/5_change_pic/core/build.gradle b/Занимательное программирование/2/5_change_pic/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/5_change_pic/core/src/net/caraus/fadein/FadeIn.java b/Занимательное программирование/2/5_change_pic/core/src/net/caraus/fadein/FadeIn.java new file mode 100644 index 0000000..34b5bf4 --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/core/src/net/caraus/fadein/FadeIn.java @@ -0,0 +1,92 @@ +package net.caraus.fadein; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.ScreenUtils; + +public class FadeIn extends ApplicationAdapter { + SpriteBatch batch; + + Texture etalonTexture; + Pixmap etalon; + + Pixmap pixmap; + Texture img; + int[][][] buffer; + + @Override + public void create () { + batch = new SpriteBatch(); + + FileHandle etalonHandle = Gdx.files.internal("badlogic.bmp"); + etalon = new Pixmap(etalonHandle); + etalonTexture = new Texture(etalon); + + FileHandle imgHandle = Gdx.files.internal("background2.bmp"); + pixmap = new Pixmap(imgHandle); + buffer = new int[pixmap.getWidth()][pixmap.getHeight()][3]; + for (int i = 0; i < pixmap.getWidth(); ++i) { + for (int j = 0; j < pixmap.getHeight(); ++j) { + int pixmapPixel = pixmap.getPixel(i, j); + + buffer[i][j][0] = (pixmapPixel >> 24) & 0xff; // Red. + buffer[i][j][1] = (pixmapPixel >> 16) & 0xff; // Green. + buffer[i][j][2] = (pixmapPixel >> 8) & 0xff; // Blue. + } + } + img = new Texture(pixmap); + } + + @Override + public void render () { + ScreenUtils.clear(1, 0, 0, 1); + + for (int i = 0; i < pixmap.getWidth(); ++i) { + for (int j = 0; j < pixmap.getHeight(); ++j) { + int etalonPixel = etalon.getPixel(i, j); + + int etalonRed = (etalonPixel >> 24) & 0xff; + int etalonGreen = (etalonPixel >> 16) & 0xff; + int etalonBlue = (etalonPixel >> 8) & 0xff; + + if (etalonRed < buffer[i][j][0]) { + --buffer[i][j][0]; + } else if (etalonRed > buffer[i][j][0]) { + ++buffer[i][j][0]; + } + if (etalonGreen < buffer[i][j][1]) { + --buffer[i][j][1]; + } else if (etalonGreen > buffer[i][j][1]) { + ++buffer[i][j][1]; + } + if (etalonBlue < buffer[i][j][2]) { + --buffer[i][j][2]; + } else if (etalonBlue > buffer[i][j][2]) { + ++buffer[i][j][2]; + } + pixmap.setColor((buffer[i][j][0] << 24) | (buffer[i][j][1] << 16) | (buffer[i][j][2] << 8) | 0xff); + pixmap.drawPixel(i, j); + } + } + img.draw(pixmap, 0, 0); + + batch.begin(); + batch.draw(etalonTexture, 0, 0); + batch.draw(img, etalon.getWidth() + 15, 0); + batch.end(); + } + + @Override + public void dispose () { + batch.dispose(); + etalonTexture.dispose(); + etalon.dispose(); + + img.dispose(); + pixmap.dispose(); + } +} diff --git a/Занимательное программирование/2/5_change_pic/desktop/build.gradle b/Занимательное программирование/2/5_change_pic/desktop/build.gradle new file mode 100644 index 0000000..446836b --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.fadein.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/5_change_pic/desktop/src/net/caraus/fadein/DesktopLauncher.java b/Занимательное программирование/2/5_change_pic/desktop/src/net/caraus/fadein/DesktopLauncher.java new file mode 100644 index 0000000..087ba87 --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/desktop/src/net/caraus/fadein/DesktopLauncher.java @@ -0,0 +1,15 @@ +package net.caraus.fadein; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import net.caraus.fadein.FadeIn; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + config.setForegroundFPS(30); + config.setTitle("Fade In"); + new Lwjgl3Application(new FadeIn(), config); + } +} diff --git a/Занимательное программирование/2/5_change_pic/gradle.properties b/Занимательное программирование/2/5_change_pic/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/5_change_pic/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/5_change_pic/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/5_change_pic/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/5_change_pic/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/5_change_pic/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/5_change_pic/gradlew b/Занимательное программирование/2/5_change_pic/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/5_change_pic/gradlew.bat b/Занимательное программирование/2/5_change_pic/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/5_change_pic/settings.gradle b/Занимательное программирование/2/5_change_pic/settings.gradle new file mode 100644 index 0000000..e362338 --- /dev/null +++ b/Занимательное программирование/2/5_change_pic/settings.gradle @@ -0,0 +1 @@ +include 'core', 'desktop' \ No newline at end of file diff --git a/Занимательное программирование/2/6_pixel/.gitignore b/Занимательное программирование/2/6_pixel/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/6_pixel/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/6_pixel/assets/badlogic.jpg b/Занимательное программирование/2/6_pixel/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/Занимательное программирование/2/6_pixel/assets/badlogic.jpg differ diff --git a/Занимательное программирование/2/6_pixel/build.gradle b/Занимательное программирование/2/6_pixel/build.gradle new file mode 100644 index 0000000..419f04a --- /dev/null +++ b/Занимательное программирование/2/6_pixel/build.gradle @@ -0,0 +1,62 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Pixel Image" + gdxVersion = '1.13.5' + roboVMVersion = '2.3.16' + box2DLightsVersion = '1.5' + ashleyVersion = '1.7.4' + aiVersion = '1.8.2' + gdxControllersVersion = '2.2.1' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} diff --git a/Занимательное программирование/2/6_pixel/core/build.gradle b/Занимательное программирование/2/6_pixel/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/6_pixel/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/6_pixel/core/src/net/caraus/pixelimage/PixelImage.java b/Занимательное программирование/2/6_pixel/core/src/net/caraus/pixelimage/PixelImage.java new file mode 100644 index 0000000..df49b3b --- /dev/null +++ b/Занимательное программирование/2/6_pixel/core/src/net/caraus/pixelimage/PixelImage.java @@ -0,0 +1,90 @@ +package net.caraus.pixelimage; + +import java.util.random.RandomGenerator; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.Pixmap.Format; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.RandomXS128; +import com.badlogic.gdx.utils.ScreenUtils; + +public class PixelImage extends ApplicationAdapter { + private SpriteBatch batch; + private Texture img; + private Pixmap canvas; + private Pixmap etalon; + private int[][][] buffer; + private static final int X_OFFSET = 200; + private static final int Y_OFFSET = 100; + private int iterations = 0; + + @Override + public void create () { + batch = new SpriteBatch(); + + FileHandle fileHandle = Gdx.files.internal("badlogic.jpg"); + etalon = new Pixmap(fileHandle); + + canvas = new Pixmap(etalon.getWidth() + X_OFFSET * 2, etalon.getHeight() + Y_OFFSET * 2, Format.RGB888); + buffer = new int[etalon.getWidth()][etalon.getHeight()][2]; + + for (int i = 0; i < buffer.length; ++i) { + for (int j = 0; j < buffer[i].length; ++j) { + buffer[i][j][0] = X_OFFSET + i; + buffer[i][j][1] = Y_OFFSET + j; + } + } + img = new Texture(canvas); + } + + @Override + public void render () { + ScreenUtils.clear(1, 1, 1, 1); + + canvas.setColor(1, 1, 1, 1); + canvas.fill(); + + // Draw the buffer. + for (int i = 0; i < buffer.length; ++i) { + for (int j = 0; j < buffer[i].length; ++j) { + int pixelColor = etalon.getPixel(i, j); + + canvas.setColor(pixelColor); + canvas.drawPixel(buffer[i][j][0], buffer[i][j][1]); + } + } + + if (iterations < 20) { + RandomGenerator randomGenerator = new RandomXS128(); + // Change the pixel position. + for (int i = 0; i < buffer.length; ++i) { + for (int j = 0; j < buffer[i].length; ++j) { + int step = 5 * iterations + 1; + int moveX = randomGenerator.nextInt(step) - step / 2; + int moveY = randomGenerator.nextInt(step) - step / 2; + + buffer[i][j][0] += moveX; + buffer[i][j][1] += moveY; + } + } + ++iterations; + } + img.draw(canvas, 0, 0); + + batch.begin(); + batch.draw(img, 0, 0); + batch.end(); + } + + @Override + public void dispose () { + batch.dispose(); + img.dispose(); + canvas.dispose(); + etalon.dispose(); + } +} diff --git a/Занимательное программирование/2/6_pixel/desktop/build.gradle b/Занимательное программирование/2/6_pixel/desktop/build.gradle new file mode 100644 index 0000000..f6ef85f --- /dev/null +++ b/Занимательное программирование/2/6_pixel/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.pixelimage.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/6_pixel/desktop/src/net/caraus/pixelimage/DesktopLauncher.java b/Занимательное программирование/2/6_pixel/desktop/src/net/caraus/pixelimage/DesktopLauncher.java new file mode 100644 index 0000000..cf5bb99 --- /dev/null +++ b/Занимательное программирование/2/6_pixel/desktop/src/net/caraus/pixelimage/DesktopLauncher.java @@ -0,0 +1,15 @@ +package net.caraus.pixelimage; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import net.caraus.pixelimage.PixelImage; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + config.setForegroundFPS(60); + config.setTitle("Pixel Image"); + new Lwjgl3Application(new PixelImage(), config); + } +} diff --git a/Занимательное программирование/2/6_pixel/gradle.properties b/Занимательное программирование/2/6_pixel/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/6_pixel/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/6_pixel/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/6_pixel/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/6_pixel/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/6_pixel/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/6_pixel/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/6_pixel/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/6_pixel/gradlew b/Занимательное программирование/2/6_pixel/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/6_pixel/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/6_pixel/gradlew.bat b/Занимательное программирование/2/6_pixel/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/6_pixel/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/6_pixel/settings.gradle b/Занимательное программирование/2/6_pixel/settings.gradle new file mode 100644 index 0000000..e362338 --- /dev/null +++ b/Занимательное программирование/2/6_pixel/settings.gradle @@ -0,0 +1 @@ +include 'core', 'desktop' \ No newline at end of file diff --git a/Занимательное программирование/2/7_curtain/.gitignore b/Занимательное программирование/2/7_curtain/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/7_curtain/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/7_curtain/assets/background2.bmp b/Занимательное программирование/2/7_curtain/assets/background2.bmp new file mode 100644 index 0000000..9d68dfc Binary files /dev/null and b/Занимательное программирование/2/7_curtain/assets/background2.bmp differ diff --git a/Занимательное программирование/2/7_curtain/assets/badlogic.bmp b/Занимательное программирование/2/7_curtain/assets/badlogic.bmp new file mode 100644 index 0000000..81caec7 Binary files /dev/null and b/Занимательное программирование/2/7_curtain/assets/badlogic.bmp differ diff --git a/Занимательное программирование/2/7_curtain/assets/badlogic.jpg b/Занимательное программирование/2/7_curtain/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/Занимательное программирование/2/7_curtain/assets/badlogic.jpg differ diff --git a/Занимательное программирование/2/7_curtain/build.gradle b/Занимательное программирование/2/7_curtain/build.gradle new file mode 100644 index 0000000..55444f4 --- /dev/null +++ b/Занимательное программирование/2/7_curtain/build.gradle @@ -0,0 +1,57 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Curtain" + gdxVersion = '1.13.5' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} diff --git a/Занимательное программирование/2/7_curtain/core/build.gradle b/Занимательное программирование/2/7_curtain/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/7_curtain/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/7_curtain/core/src/net/caraus/curtain/Curtain.java b/Занимательное программирование/2/7_curtain/core/src/net/caraus/curtain/Curtain.java new file mode 100644 index 0000000..515651f --- /dev/null +++ b/Занимательное программирование/2/7_curtain/core/src/net/caraus/curtain/Curtain.java @@ -0,0 +1,49 @@ +package net.caraus.curtain; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.utils.ScreenUtils; + +public class Curtain extends ApplicationAdapter { + SpriteBatch batch; + Texture background; + Texture foreground; + TextureRegion leftRegion; + TextureRegion rightRegion; + int delta = 0; + + @Override + public void create () { + batch = new SpriteBatch(); + background = new Texture("badlogic.bmp"); + foreground = new Texture("background2.bmp"); + } + + @Override + public void render () { + ScreenUtils.clear(1, 0, 0, 1); + + leftRegion = new TextureRegion(foreground, 128 - delta, 256); + rightRegion = new TextureRegion(foreground, 128, 0, 128 - delta, 256); + + batch.begin(); + batch.draw(background, 0, 0); + + if (delta < 128) { + batch.draw(leftRegion, 0 - delta, 0); + batch.draw(rightRegion, 128 + delta, 0); + } + batch.end(); + + ++delta; + } + + @Override + public void dispose () { + batch.dispose(); + background.dispose(); + foreground.dispose(); + } +} diff --git a/Занимательное программирование/2/7_curtain/desktop/build.gradle b/Занимательное программирование/2/7_curtain/desktop/build.gradle new file mode 100644 index 0000000..9904a79 --- /dev/null +++ b/Занимательное программирование/2/7_curtain/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.curtain.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/7_curtain/desktop/src/net/caraus/curtain/DesktopLauncher.java b/Занимательное программирование/2/7_curtain/desktop/src/net/caraus/curtain/DesktopLauncher.java new file mode 100644 index 0000000..9a0667b --- /dev/null +++ b/Занимательное программирование/2/7_curtain/desktop/src/net/caraus/curtain/DesktopLauncher.java @@ -0,0 +1,15 @@ +package net.caraus.curtain; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import net.caraus.curtain.Curtain; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + config.setForegroundFPS(60); + config.setTitle("Curtain"); + new Lwjgl3Application(new Curtain(), config); + } +} diff --git a/Занимательное программирование/2/7_curtain/gradle.properties b/Занимательное программирование/2/7_curtain/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/7_curtain/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/7_curtain/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/7_curtain/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/7_curtain/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/7_curtain/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/7_curtain/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/7_curtain/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/7_curtain/gradlew b/Занимательное программирование/2/7_curtain/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/7_curtain/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/7_curtain/gradlew.bat b/Занимательное программирование/2/7_curtain/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/7_curtain/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/7_curtain/settings.gradle b/Занимательное программирование/2/7_curtain/settings.gradle new file mode 100644 index 0000000..e362338 --- /dev/null +++ b/Занимательное программирование/2/7_curtain/settings.gradle @@ -0,0 +1 @@ +include 'core', 'desktop' \ No newline at end of file diff --git a/Занимательное программирование/2/8_turtle/.gitignore b/Занимательное программирование/2/8_turtle/.gitignore new file mode 100644 index 0000000..3d9d087 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/.gitignore @@ -0,0 +1,114 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +/android/libs/armeabi-v7a/ +/android/libs/arm64-v8a/ +/android/libs/x86/ +/android/libs/x86_64/ +/android/gen/ +.idea/ +*.ipr +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.atlas b/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.atlas new file mode 100644 index 0000000..72ae2f0 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.atlas @@ -0,0 +1,512 @@ + +clean-crispy-ui.png +size: 512,512 +format: RGBA8888 +filter: Linear,Linear +repeat: none +button + rotate: false + xy: 267, 473 + size: 38, 38 + split: 8, 10, 9, 10 + pad: 8, 10, 4, 6 + orig: 38, 38 + offset: 0, 0 + index: -1 +button-arcade + rotate: false + xy: 115, 427 + size: 84, 84 + split: 0, 0, 0, 0 + pad: 18, 18, 25, 38 + orig: 84, 84 + offset: 0, 0 + index: -1 +button-arcade-pressed + rotate: false + xy: 1, 213 + size: 84, 84 + split: 0, 0, 0, 0 + pad: 18, 18, 30, 33 + orig: 84, 84 + offset: 0, 0 + index: -1 +button-close + rotate: false + xy: 74, 51 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-close-over + rotate: false + xy: 101, 309 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-close-pressed + rotate: false + xy: 118, 369 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-maximize + rotate: false + xy: 118, 351 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-maximize-over + rotate: false + xy: 135, 369 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-maximize-pressed + rotate: false + xy: 118, 333 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-minimize + rotate: false + xy: 135, 351 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-minimize-over + rotate: false + xy: 152, 369 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-minimize-pressed + rotate: false + xy: 118, 315 + size: 15, 16 + orig: 15, 16 + offset: 0, 0 + index: -1 +button-over + rotate: false + xy: 307, 473 + size: 38, 38 + split: 8, 10, 9, 10 + pad: 8, 10, 4, 6 + orig: 38, 38 + offset: 0, 0 + index: -1 +button-pressed + rotate: false + xy: 347, 473 + size: 38, 38 + split: 8, 10, 9, 10 + pad: 8, 10, 4, 6 + orig: 38, 38 + offset: 0, 0 + index: -1 +button-pressed-over + rotate: false + xy: 387, 473 + size: 38, 38 + split: 8, 10, 9, 10 + pad: 8, 10, 4, 6 + orig: 38, 38 + offset: 0, 0 + index: -1 +checkbox + rotate: false + xy: 54, 81 + size: 18, 17 + orig: 18, 17 + offset: 0, 0 + index: -1 +checkbox-over + rotate: false + xy: 54, 62 + size: 18, 17 + orig: 18, 17 + offset: 0, 0 + index: -1 +checkbox-pressed + rotate: false + xy: 54, 43 + size: 18, 17 + orig: 18, 17 + offset: 0, 0 + index: -1 +checkbox-pressed-over + rotate: false + xy: 76, 126 + size: 18, 17 + orig: 18, 17 + offset: 0, 0 + index: -1 +cursor + rotate: false + xy: 1, 3 + size: 2, 6 + split: 0, 0, 1, 1 + pad: 0, 0, 0, 0 + orig: 2, 6 + offset: 0, 0 + index: -1 +font-export + rotate: false + xy: 1, 299 + size: 98, 98 + orig: 98, 98 + offset: 0, 0 + index: -1 +list + rotate: false + xy: 41, 1 + size: 37, 35 + split: 6, 8, 4, 8 + pad: 7, 9, 2, 6 + orig: 37, 35 + offset: 0, 0 + index: -1 +progressbar-big + rotate: false + xy: 267, 440 + size: 31, 31 + split: 10, 10, 6, 9 + pad: 1, 1, 0, 0 + orig: 31, 31 + offset: 0, 0 + index: -1 +progressbar-horizontal + rotate: false + xy: 267, 426 + size: 23, 12 + split: 5, 5, 3, 3 + pad: 3, 3, 0, 0 + orig: 23, 12 + offset: 0, 0 + index: -1 +progressbar-knob-big + rotate: false + xy: 64, 145 + size: 24, 26 + orig: 24, 26 + offset: 0, 0 + index: -1 +progressbar-knob-horizontal + rotate: false + xy: 135, 323 + size: 1, 12 + orig: 1, 12 + offset: 0, 0 + index: -1 +progressbar-knob-vertical + rotate: false + xy: 101, 396 + size: 12, 1 + orig: 12, 1 + offset: 0, 0 + index: -1 +progressbar-tiled + rotate: false + xy: 135, 337 + size: 15, 12 + orig: 15, 12 + offset: 0, 0 + index: -1 +progressbar-vertical + rotate: false + xy: 499, 448 + size: 12, 23 + split: 0, 12, 5, 6 + pad: 0, 0, 3, 3 + orig: 12, 23 + offset: 0, 0 + index: -1 +radio + rotate: false + xy: 91, 196 + size: 20, 20 + orig: 20, 20 + offset: 0, 0 + index: -1 +radio-over + rotate: false + xy: 91, 174 + size: 20, 20 + orig: 20, 20 + offset: 0, 0 + index: -1 +radio-pressed + rotate: false + xy: 54, 122 + size: 20, 20 + orig: 20, 20 + offset: 0, 0 + index: -1 +radio-pressed-over + rotate: false + xy: 54, 100 + size: 20, 20 + orig: 20, 20 + offset: 0, 0 + index: -1 +resize + rotate: false + xy: 169, 375 + size: 10, 10 + orig: 10, 10 + offset: 0, 0 + index: -1 +scrollpane-horizontal + rotate: false + xy: 201, 428 + size: 31, 17 + split: 11, 12, 0, 0 + pad: 0, 0, 0, 0 + orig: 31, 17 + offset: 0, 0 + index: -1 +scrollpane-knob-horizontal + rotate: false + xy: 234, 428 + size: 31, 17 + split: 6, 8, 0, 0 + pad: 0, 0, 0, 0 + orig: 31, 17 + offset: 0, 0 + index: -1 +scrollpane-knob-vertical + rotate: false + xy: 74, 69 + size: 17, 28 + split: 0, 0, 4, 7 + pad: 0, 0, 0, 0 + orig: 17, 28 + offset: 0, 0 + index: -1 +scrollpane-vertical + rotate: false + xy: 195, 393 + size: 17, 32 + split: 0, 0, 11, 13 + pad: 0, 0, 0, 0 + orig: 17, 32 + offset: 0, 0 + index: -1 +selectbox + rotate: false + xy: 427, 473 + size: 38, 38 + split: 7, 17, 15, 18 + pad: 5, 17, 4, 7 + orig: 38, 38 + offset: 0, 0 + index: -1 +selectbox-over + rotate: false + xy: 467, 473 + size: 38, 38 + split: 8, 15, 15, 18 + pad: 5, 17, 4, 7 + orig: 38, 38 + offset: 0, 0 + index: -1 +selectbox-pressed + rotate: false + xy: 115, 387 + size: 38, 38 + split: 8, 15, 15, 18 + pad: 5, 17, 4, 7 + orig: 38, 38 + offset: 0, 0 + index: -1 +selectbox-pressed-over + rotate: false + xy: 155, 387 + size: 38, 38 + split: 8, 15, 15, 18 + pad: 5, 17, 5, 7 + orig: 38, 38 + offset: 0, 0 + index: -1 +slider-bar-horizontal + rotate: false + xy: 152, 342 + size: 11, 25 + split: 10, 0, 0, 0 + pad: 0, 0, 0, 0 + orig: 11, 25 + offset: 0, 0 + index: -1 +slider-bar-vertical + rotate: false + xy: 472, 457 + size: 25, 14 + split: 0, 0, 0, 13 + pad: 0, 0, 0, 0 + orig: 25, 14 + offset: 0, 0 + index: -1 +slider-horizontal + rotate: false + xy: 1, 11 + size: 38, 25 + split: 18, 18, 0, 0 + pad: 3, 0, 0, 0 + orig: 38, 25 + offset: 0, 0 + index: -1 +slider-knob-horizontal + rotate: false + xy: 87, 272 + size: 21, 25 + orig: 21, 25 + offset: 0, 0 + index: -1 +slider-knob-over-horizontal + rotate: false + xy: 87, 245 + size: 21, 25 + orig: 21, 25 + offset: 0, 0 + index: -1 +slider-knob-over-vertical + rotate: false + xy: 391, 450 + size: 25, 21 + orig: 25, 21 + offset: 0, 0 + index: -1 +slider-knob-pressed-horizontal + rotate: false + xy: 87, 218 + size: 21, 25 + orig: 21, 25 + offset: 0, 0 + index: -1 +slider-knob-pressed-vertical + rotate: false + xy: 418, 450 + size: 25, 21 + orig: 25, 21 + offset: 0, 0 + index: -1 +slider-knob-vertical + rotate: false + xy: 445, 450 + size: 25, 21 + orig: 25, 21 + offset: 0, 0 + index: -1 +slider-tick + rotate: false + xy: 76, 99 + size: 17, 25 + orig: 17, 25 + offset: 0, 0 + index: -1 +slider-vertical + rotate: false + xy: 64, 173 + size: 25, 38 + split: 0, 0, 18, 18 + pad: 0, 0, 0, 3 + orig: 25, 38 + offset: 0, 0 + index: -1 +splitpane-horizontal + rotate: false + xy: 292, 429 + size: 3, 9 + split: 0, 0, 1, 1 + pad: 0, 0, 0, 0 + orig: 3, 9 + offset: 0, 0 + index: -1 +splitpane-vertical + rotate: false + xy: 54, 38 + size: 9, 3 + split: 1, 1, 1, 1 + pad: 0, 0, 0, 0 + orig: 9, 3 + offset: 0, 0 + index: -1 +textfield + rotate: false + xy: 362, 444 + size: 27, 27 + split: 8, 6, 6, 7 + pad: 3, 3, 2, 2 + orig: 27, 27 + offset: 0, 0 + index: -1 +tooltip + rotate: false + xy: 1, 38 + size: 51, 104 + split: 10, 9, 9, 10 + pad: 10, 10, 2, 3 + orig: 51, 104 + offset: 0, 0 + index: -1 +touchpad + rotate: false + xy: 1, 399 + size: 112, 112 + orig: 112, 112 + offset: 0, 0 + index: -1 +touchpad-knob + rotate: false + xy: 201, 447 + size: 64, 64 + orig: 64, 64 + offset: 0, 0 + index: -1 +tree-minus + rotate: false + xy: 300, 448 + size: 29, 23 + orig: 29, 23 + offset: 0, 0 + index: -1 +tree-plus + rotate: false + xy: 331, 448 + size: 29, 23 + orig: 29, 23 + offset: 0, 0 + index: -1 +white + rotate: false + xy: 300, 445 + size: 1, 1 + orig: 1, 1 + offset: 0, 0 + index: -1 +window + rotate: false + xy: 1, 144 + size: 61, 67 + split: 10, 12, 23, 13 + pad: 12, 14, 25, 7 + orig: 61, 67 + offset: 0, 0 + index: -1 +window-main + rotate: false + xy: 101, 327 + size: 15, 58 + split: 1, 1, 21, 16 + pad: -1, -1, 23, 1 + orig: 15, 58 + offset: 0, 0 + index: -1 diff --git a/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.json b/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.json new file mode 100644 index 0000000..f0488c3 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.json @@ -0,0 +1,498 @@ +{ +com.badlogic.gdx.graphics.g2d.BitmapFont: { + font: { + file: font-export.fnt + } +} +com.badlogic.gdx.graphics.Color: { + color: { + r: 1 + g: 1 + b: 1 + a: 1 + } + selection: { + r: 0.70333326 + g: 0.70333326 + b: 0.70333326 + a: 1 + } +} +com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable: { + button-c: { + name: button + color: color + } + button-arcade-c: { + name: button-arcade + color: color + } + button-arcade-pressed-c: { + name: button-arcade-pressed + color: color + } + button-close-c: { + name: button-close + color: color + } + button-close-over-c: { + name: button-close-over + color: color + } + button-close-pressed-c: { + name: button-close-pressed + color: color + } + button-maximize-c: { + name: button-maximize + color: color + } + button-maximize-over-c: { + name: button-maximize-over + color: color + } + button-maximize-pressed-c: { + name: button-maximize-pressed + color: color + } + button-minimize-c: { + name: button-minimize + color: color + } + button-minimize-over-c: { + name: button-minimize-over + color: color + } + button-minimize-pressed-c: { + name: button-minimize-pressed + color: color + } + button-over-c: { + name: button-over + color: color + } + button-pressed-c: { + name: button-pressed + color: color + } + button-pressed-over-c: { + name: button-pressed-over + color: color + } + checkbox-c: { + name: checkbox + color: color + } + checkbox-over-c: { + name: checkbox-over + color: color + } + checkbox-pressed-c: { + name: checkbox-pressed + color: color + } + checkbox-pressed-over-c: { + name: checkbox-pressed-over + color: color + } + cursor-c: { + name: cursor + color: color + } + list-c: { + name: list + color: color + } + progressbar-big-c: { + name: progressbar-big + color: color + } + progressbar-horizontal-c: { + name: progressbar-horizontal + color: color + } + progressbar-knob-horizontal-c: { + name: progressbar-knob-horizontal + color: color + } + progressbar-knob-vertical-c: { + name: progressbar-knob-vertical + color: color + } + progressbar-vertical-c: { + name: progressbar-vertical + color: color + } + radio-c: { + name: radio + color: color + } + radio-over-c: { + name: radio-over + color: color + } + radio-pressed-c: { + name: radio-pressed + color: color + } + radio-pressed-over-c: { + name: radio-pressed-over + color: color + } + selectbox-c: { + name: selectbox + color: color + } + selectbox-over-c: { + name: selectbox-over + color: color + } + selectbox-pressed-c: { + name: selectbox-pressed + color: color + } + selectbox-pressed-over-c: { + name: selectbox-pressed-over + color: color + } + slider-horizontal-c: { + name: slider-horizontal + color: color + } + slider-knob-horizontal-c: { + name: slider-knob-horizontal + color: color + } + slider-knob-over-horizontal-c: { + name: slider-knob-over-horizontal + color: color + } + slider-knob-over-vertical-c: { + name: slider-knob-over-vertical + color: color + } + slider-knob-pressed-horizontal-c: { + name: slider-knob-pressed-horizontal + color: color + } + slider-knob-pressed-vertical-c: { + name: slider-knob-pressed-vertical + color: color + } + slider-knob-vertical-c: { + name: slider-knob-vertical + color: color + } + slider-vertical-c: { + name: slider-vertical + color: color + } + splitpane-horizontal-c: { + name: splitpane-horizontal + color: color + } + splitpane-vertical-c: { + name: splitpane-vertical + color: color + } + textfield-c: { + name: textfield + color: color + } + tooltip-c: { + name: tooltip + color: color + } + touchpad-c: { + name: touchpad + color: color + } + touchpad-knob-c: { + name: touchpad-knob + color: color + } + tree-minus-c: { + name: tree-minus + color: color + } + tree-plus-c: { + name: tree-plus + color: color + } + window-c: { + name: window + color: color + } + window-main-c: { + name: window-main + color: color + } + color: { + name: white + color: color + } + scrollpane-horizontal-c: { + name: scrollpane-horizontal + color: color + } + scrollpane-knob-horizontal-c: { + name: scrollpane-knob-horizontal + color: color + } + scrollpane-knob-vertical-c: { + name: scrollpane-knob-vertical + color: color + } + scrollpane-vertical-c: { + name: scrollpane-vertical + color: color + } + slider-bar-horizontal-c: { + name: slider-bar-horizontal + color: color + } + slider-bar-vertical-c: { + name: slider-bar-vertical + color: color + } + selection: { + name: white + color: selection + } +} +com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: { + default: { + up: button-c + down: button-pressed-over-c + over: button-over-c + } + toggle: { + up: button-c + down: button-pressed-c + over: button-over-c + checked: button-pressed-c + checkedOver: button-pressed-over-c + } + minimize: { + up: button-minimize-c + down: button-minimize-pressed-c + over: button-minimize-over-c + } + maximize: { + up: button-maximize-c + down: button-maximize-pressed-c + over: button-maximize-over-c + } + close: { + up: button-close-c + down: button-close-pressed-c + over: button-close-over-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle: { + default: { + checkboxOn: checkbox-pressed-c + checkboxOff: checkbox-c + checkboxOver: checkbox-over-c + font: font + fontColor: color + } + radio: { + checkboxOn: radio-pressed-c + checkboxOff: radio-c + checkboxOver: radio-over-c + font: font + fontColor: color + } +} +com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: { + default: { + up: button-c + down: button-pressed-over-c + over: button-over-c + } + toggle: { + up: button-c + down: button-pressed-c + over: button-over-c + checked: button-pressed-c + checkedOver: button-pressed-over-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton$ImageTextButtonStyle: { + default: { + font: font + up: button-c + down: button-pressed-over-c + over: button-over-c + } + toggle: { + font: font + up: button-c + down: button-pressed-c + over: button-over-c + checked: button-pressed-c + checkedOver: button-pressed-over-c + } + radio: { + imageUp: radio-c + imageDown: radio-pressed-c + imageOver: radio-over-c + imageChecked: radio-pressed-c + imageCheckedOver: radio-pressed-over-c + font: font + } + checkbox: { + imageUp: checkbox-c + imageDown: checkbox-pressed-c + imageOver: checkbox-over-c + imageChecked: checkbox-pressed-c + imageCheckedOver: checkbox-pressed-over-c + font: font + } +} +com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: { + default: { + font: font + fontColor: color + } +} +com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle: { + default: { + font: font + fontColorSelected: color + fontColorUnselected: color + selection: color + background: list-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.ProgressBar$ProgressBarStyle: { + default-horizontal: { + background: progressbar-horizontal-c + knobBefore: progressbar-knob-horizontal-c + } + default-vertical: { + background: progressbar-vertical-c + knobBefore: progressbar-knob-vertical-c + } + tiled: { + background: progressbar-horizontal-c + knobBefore: progressbar-tiled + } + tiled-big: { + background: progressbar-big-c + knobBefore: progressbar-knob-big + } +} +com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: { + default: { + hScroll: scrollpane-horizontal-c + hScrollKnob: scrollpane-knob-horizontal-c + vScroll: scrollpane-vertical-c + vScrollKnob: scrollpane-knob-vertical-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle: { + default: { + font: font + fontColor: color + background: selectbox-c + scrollStyle: default + listStyle: default + backgroundOver: selectbox-over-c + backgroundOpen: selectbox-pressed-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: { + default-horizontal: { + knobOver: slider-knob-over-horizontal-c + knobDown: slider-knob-pressed-horizontal-c + background: slider-horizontal + knob: slider-knob-horizontal-c + knobBefore: slider-bar-horizontal-c + } + default-vertical: { + knobOver: slider-knob-over-vertical-c + knobDown: slider-knob-pressed-vertical-c + background: slider-vertical-c + knob: slider-knob-vertical-c + knobBefore: slider-bar-vertical-c + } + tick: { + knobOver: slider-knob-over-horizontal-c + knobDown: slider-knob-pressed-horizontal-c + background: slider-tick + knob: slider-knob-horizontal-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle: { + default-horizontal: { + handle: splitpane-horizontal-c + } + default-vertical: { + handle: splitpane-vertical-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: { + default: { + font: font + fontColor: color + up: button-c + down: button-pressed-over-c + over: button-over-c + } + toggle: { + font: font + fontColor: color + up: button-c + down: button-pressed-c + over: button-over-c + checked: button-pressed-c + checkedOver: button-pressed-over-c + } + arcade: { + font: font + up: button-arcade-c + down: button-arcade-pressed-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: { + default: { + font: font + fontColor: color + background: textfield-c + cursor: cursor-c + selection: selection + } +} +com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: { + default: { + label: default + background: tooltip-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle: { + default: { + background: touchpad-c + knob: touchpad-knob-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle: { + default: { + plus: tree-plus-c + minus: tree-minus-c + } +} +com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: { + default: { + background: window-c + titleFont: font + titleFontColor: color + } + main: { + background: window-main-c + titleFont: font + titleFontColor: color + } +} +} \ No newline at end of file diff --git a/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.png b/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.png new file mode 100644 index 0000000..b6b062b Binary files /dev/null and b/Занимательное программирование/2/8_turtle/assets/skin/clean-crispy-ui.png differ diff --git a/Занимательное программирование/2/8_turtle/assets/skin/font-export.fnt b/Занимательное программирование/2/8_turtle/assets/skin/font-export.fnt new file mode 100644 index 0000000..8874161 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/assets/skin/font-export.fnt @@ -0,0 +1,104 @@ +info face="font-export" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 +common lineHeight=16 base=16 scaleW=98 scaleH=98 pages=1 packed=0 alphaChnl=1 redChnl=0 greenChnl=0 blueChnl=0 +page id=0 file="font-export.png" +chars count=98 +char id=33 x=91 y=85 width=3 height=12 xoffset=0 yoffset=4 xadvance=4 page=0 chnl=0 letter="!" +char id=34 x=82 y=90 width=4 height=5 xoffset=0 yoffset=4 xadvance=5 page=0 chnl=0 letter=""" +char id=35 x=32 y=26 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="#" +char id=36 x=66 y=72 width=7 height=14 xoffset=0 yoffset=3 xadvance=8 page=0 chnl=0 letter="$" +char id=37 x=0 y=68 width=11 height=12 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 letter="%" +char id=38 x=12 y=78 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="&" +char id=39 x=29 y=91 width=2 height=5 xoffset=0 yoffset=4 xadvance=3 page=0 chnl=0 letter="'" +char id=40 x=89 y=32 width=4 height=15 xoffset=0 yoffset=4 xadvance=5 page=0 chnl=0 letter="(" +char id=41 x=89 y=48 width=4 height=15 xoffset=0 yoffset=4 xadvance=5 page=0 chnl=0 letter=")" +char id=42 x=17 y=91 width=5 height=6 xoffset=0 yoffset=4 xadvance=6 page=0 chnl=0 letter="*" +char id=43 x=66 y=87 width=7 height=8 xoffset=0 yoffset=6 xadvance=8 page=0 chnl=0 letter="+" +char id=44 x=93 y=64 width=3 height=5 xoffset=0 yoffset=12 xadvance=4 page=0 chnl=0 letter="," +char id=45 x=23 y=91 width=5 height=3 xoffset=0 yoffset=10 xadvance=6 page=0 chnl=0 letter="-" +char id=46 x=87 y=90 width=3 height=4 xoffset=0 yoffset=12 xadvance=4 page=0 chnl=0 letter="." +char id=47 x=82 y=76 width=6 height=13 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=0 letter="/" +char id=48 x=75 y=23 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="0" +char id=49 x=83 y=31 width=4 height=12 xoffset=0 yoffset=4 xadvance=5 page=0 chnl=0 letter="1" +char id=50 x=67 y=52 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="2" +char id=51 x=67 y=26 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="3" +char id=52 x=24 y=13 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="4" +char id=53 x=33 y=13 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="5" +char id=54 x=60 y=0 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="6" +char id=55 x=67 y=13 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="7" +char id=56 x=74 y=78 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="8" +char id=57 x=67 y=39 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="9" +char id=58 x=89 y=64 width=3 height=9 xoffset=0 yoffset=7 xadvance=4 page=0 chnl=0 letter=":" +char id=59 x=89 y=74 width=3 height=10 xoffset=0 yoffset=7 xadvance=4 page=0 chnl=0 letter=";" +char id=60 x=75 y=13 width=7 height=9 xoffset=0 yoffset=6 xadvance=8 page=0 chnl=0 letter="<" +char id=61 x=74 y=91 width=7 height=6 xoffset=0 yoffset=8 xadvance=8 page=0 chnl=0 letter="=" +char id=62 x=75 y=36 width=7 height=9 xoffset=0 yoffset=6 xadvance=8 page=0 chnl=0 letter=">" +char id=63 x=68 y=0 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="?" +char id=64 x=0 y=0 width=13 height=15 xoffset=0 yoffset=4 xadvance=14 page=0 chnl=0 letter="@" +char id=65 x=22 y=78 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="A" +char id=66 x=74 y=65 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="B" +char id=67 x=12 y=65 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="C" +char id=68 x=22 y=52 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="D" +char id=69 x=22 y=65 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="E" +char id=70 x=41 y=85 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="F" +char id=71 x=24 y=0 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="G" +char id=72 x=43 y=0 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="H" +char id=73 x=94 y=16 width=3 height=12 xoffset=0 yoffset=4 xadvance=4 page=0 chnl=0 letter="I" +char id=74 x=59 y=59 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="J" +char id=75 x=42 y=13 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="K" +char id=76 x=50 y=26 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="L" +char id=77 x=0 y=55 width=11 height=12 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 letter="M" +char id=78 x=12 y=39 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="N" +char id=79 x=0 y=42 width=11 height=12 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 letter="O" +char id=80 x=59 y=13 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="P" +char id=81 x=0 y=29 width=11 height=12 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 letter="Q" +char id=82 x=50 y=39 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="R" +char id=83 x=52 y=0 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="S" +char id=84 x=50 y=52 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="T" +char id=85 x=50 y=65 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="U" +char id=86 x=12 y=52 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="V" +char id=87 x=12 y=16 width=11 height=12 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 letter="W" +char id=88 x=14 y=0 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="X" +char id=89 x=41 y=72 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="Y" +char id=90 x=22 y=39 width=9 height=12 xoffset=0 yoffset=4 xadvance=10 page=0 chnl=0 letter="Z" +char id=91 x=83 y=0 width=5 height=15 xoffset=0 yoffset=4 xadvance=6 page=0 chnl=0 letter="[" +char id=92 x=82 y=62 width=6 height=13 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=0 letter="\" +char id=93 x=89 y=16 width=4 height=15 xoffset=0 yoffset=4 xadvance=5 page=0 chnl=0 letter="]" +char id=94 x=67 y=65 width=6 height=6 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=0 letter="^" +char id=95 x=0 y=91 width=8 height=3 xoffset=0 yoffset=14 xadvance=9 page=0 chnl=0 letter="_" +char id=96 x=75 y=59 width=4 height=5 xoffset=0 yoffset=4 xadvance=5 page=0 chnl=0 letter="`" +char id=97 x=41 y=52 width=8 height=9 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="a" +char id=98 x=41 y=39 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="b" +char id=99 x=58 y=78 width=7 height=9 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 letter="c" +char id=100 x=34 y=0 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="d" +char id=101 x=41 y=62 width=8 height=9 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="e" +char id=102 x=76 y=0 width=6 height=12 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=0 letter="f" +char id=103 x=32 y=62 width=8 height=12 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="g" +char id=104 x=32 y=49 width=8 height=12 xoffset=0 yoffset=4 xadvance=9 page=0 chnl=0 letter="h" +char id=105 x=94 y=45 width=2 height=11 xoffset=0 yoffset=5 xadvance=3 page=0 chnl=0 letter="i" +char id=106 x=83 y=16 width=5 height=14 xoffset=0 yoffset=5 xadvance=6 page=0 chnl=0 letter="j" +char id=107 x=51 y=13 width=7 height=12 xoffset=0 yoffset=4 xadvance=8 page=0 chnl=0 letter="k" +char id=108 x=93 y=70 width=3 height=12 xoffset=0 yoffset=4 xadvance=4 page=0 chnl=0 letter="l" +char id=109 x=0 y=81 width=11 height=9 xoffset=0 yoffset=7 xadvance=12 page=0 chnl=0 letter="m" +char id=110 x=50 y=88 width=7 height=9 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 letter="n" +char id=111 x=32 y=39 width=8 height=9 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="o" +char id=112 x=41 y=26 width=8 height=12 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="p" +char id=113 x=32 y=85 width=8 height=12 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="q" +char id=114 x=50 y=78 width=7 height=9 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 letter="r" +char id=115 x=58 y=88 width=7 height=9 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 letter="s" +char id=116 x=75 y=46 width=6 height=12 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=0 letter="t" +char id=117 x=23 y=29 width=8 height=9 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="u" +char id=118 x=32 y=75 width=8 height=9 xoffset=0 yoffset=7 xadvance=9 page=0 chnl=0 letter="v" +char id=119 x=12 y=29 width=10 height=9 xoffset=0 yoffset=7 xadvance=11 page=0 chnl=0 letter="w" +char id=120 x=59 y=26 width=7 height=9 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 letter="x" +char id=121 x=59 y=46 width=7 height=12 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 letter="y" +char id=122 x=59 y=36 width=7 height=9 xoffset=0 yoffset=7 xadvance=8 page=0 chnl=0 letter="z" +char id=123 x=82 y=46 width=6 height=15 xoffset=0 yoffset=4 xadvance=7 page=0 chnl=0 letter="{" +char id=124 x=94 y=29 width=3 height=15 xoffset=0 yoffset=4 xadvance=4 page=0 chnl=0 letter="|" +char id=125 x=89 y=0 width=5 height=15 xoffset=0 yoffset=4 xadvance=6 page=0 chnl=0 letter="}" +char id=126 x=9 y=91 width=7 height=3 xoffset=0 yoffset=9 xadvance=8 page=0 chnl=0 letter="~" +char id=8226 x=59 y=72 width=4 height=5 xoffset=0 yoffset=8 xadvance=5 page=0 chnl=0 letter="•" +char id=169 x=0 y=16 width=11 height=12 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 letter="©" +char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=4 page=0 chnl=0 letter=" " +char id=9 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=32 page=0 chnl=0 letter=" " + +kernings count=0 diff --git a/Занимательное программирование/2/8_turtle/assets/turtle.png b/Занимательное программирование/2/8_turtle/assets/turtle.png new file mode 100644 index 0000000..587e0e0 Binary files /dev/null and b/Занимательное программирование/2/8_turtle/assets/turtle.png differ diff --git a/Занимательное программирование/2/8_turtle/build.gradle b/Занимательное программирование/2/8_turtle/build.gradle new file mode 100644 index 0000000..07e5462 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/build.gradle @@ -0,0 +1,57 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "Turtle" + gdxVersion = '1.13.5' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + maven { url "https://jitpack.io" } + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + + } +} diff --git a/Занимательное программирование/2/8_turtle/core/build.gradle b/Занимательное программирование/2/8_turtle/core/build.gradle new file mode 100644 index 0000000..c2fa637 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/core/build.gradle @@ -0,0 +1,5 @@ +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + +eclipse.project.name = appName + "-core" diff --git a/Занимательное программирование/2/8_turtle/core/src/net/caraus/turtle/Turtle.java b/Занимательное программирование/2/8_turtle/core/src/net/caraus/turtle/Turtle.java new file mode 100644 index 0000000..ff7fc99 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/core/src/net/caraus/turtle/Turtle.java @@ -0,0 +1,154 @@ +package net.caraus.turtle; + +import java.util.ArrayList; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup; +import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.ui.TextField; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.ScreenUtils; + +public class Turtle extends ApplicationAdapter { + SpriteBatch batch; + Texture img; + TextButton goButton; + TextButton moveButton; + TextButton applyButton; + HorizontalGroup container; + Stage stage; + TextField textField; + SelectBox selectBox; + Sprite turtle; + int turtleX = 110; + int turtleY = 110; + boolean isDrawing = false; + ShapeRenderer shapeRenderer; + ArrayList beginnings = new ArrayList(); + ArrayList endings = new ArrayList(); + + @Override + public void create () { + batch = new SpriteBatch(); + img = new Texture("turtle.png"); + turtle = new Sprite(img); + + stage = new Stage(); + stage.getViewport().getCamera().position.y = 20; + stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); + Gdx.input.setInputProcessor(stage); + container = new HorizontalGroup(); + container.setFillParent(true); + stage.addActor(container); + + Skin skin = new Skin(Gdx.files.internal("skin/clean-crispy-ui.json")); + + textField = new TextField(null, skin); + container.addActor(textField); + + selectBox = new SelectBox(skin); + selectBox.setItems("Oben", "Unten", "Links", "Rechts"); + container.addActor(selectBox); + + goButton = new TextButton("Zeichnen", skin); + goButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) + { + isDrawing = true; + } + }); + container.addActor(goButton); + + moveButton = new TextButton("Bewegen", skin); + moveButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) + { + isDrawing = false; + } + }); + container.addActor(moveButton); + + applyButton = new TextButton("Anwenden", skin); + applyButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) + { + try { + int value = Integer.parseInt(textField.getText()); + + if (isDrawing) { + beginnings.add(new Vector2(turtleX, turtleY)); + } + switch (selectBox.getSelected()) { + case "Oben": + turtleY += value; + break; + case "Unten": + turtleY -= value; + break; + case "Links": + turtleX -= value; + break; + case "Rechts": + turtleX += value; + break; + default: + break; + } + if (isDrawing) { + endings.add(new Vector2(turtleX, turtleY)); + } + } catch (NumberFormatException e) { + } + } + }); + container.addActor(applyButton); + + shapeRenderer = new ShapeRenderer(); + shapeRenderer.setColor(0, 0, 0, 1); + } + + @Override + public void render () { + ScreenUtils.clear(1, 1, 1, 1); + + stage.act(Gdx.graphics.getDeltaTime()); + stage.draw(); + + shapeRenderer.begin(ShapeType.Filled); + + for (int i = 0; i < beginnings.size(); ++i) { + shapeRenderer.rectLine(beginnings.get(i), endings.get(i), 5); + } + + shapeRenderer.end(); + + batch.begin(); + + turtle.setPosition(turtleX, turtleY); + turtle.draw(batch); + + batch.end(); + } + + @Override + public void dispose () { + batch.dispose(); + img.dispose(); + stage.dispose(); + shapeRenderer.dispose(); + } +} diff --git a/Занимательное программирование/2/8_turtle/desktop/build.gradle b/Занимательное программирование/2/8_turtle/desktop/build.gradle new file mode 100644 index 0000000..82ce8b7 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/desktop/build.gradle @@ -0,0 +1,46 @@ +sourceSets.main.java.srcDirs = [ "src/" ] +sourceSets.main.resources.srcDirs = ["../assets"] + +project.ext.mainClassName = "net.caraus.turtle.DesktopLauncher" +project.ext.assetsDir = new File("../assets") + +import org.gradle.internal.os.OperatingSystem + +task run(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + + if (OperatingSystem.current() == OperatingSystem.MAC_OS) { + // Required to run on macOS + jvmArgs += "-XstartOnFirstThread" + } +} + +task debug(dependsOn: classes, type: JavaExec) { + mainClass = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/Занимательное программирование/2/8_turtle/desktop/src/net/caraus/turtle/DesktopLauncher.java b/Занимательное программирование/2/8_turtle/desktop/src/net/caraus/turtle/DesktopLauncher.java new file mode 100644 index 0000000..a6b6822 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/desktop/src/net/caraus/turtle/DesktopLauncher.java @@ -0,0 +1,15 @@ +package net.caraus.turtle; + +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import net.caraus.turtle.Turtle; + +// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument +public class DesktopLauncher { + public static void main (String[] arg) { + Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); + config.setForegroundFPS(60); + config.setTitle("Turtle"); + new Lwjgl3Application(new Turtle(), config); + } +} diff --git a/Занимательное программирование/2/8_turtle/gradle.properties b/Занимательное программирование/2/8_turtle/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/Занимательное программирование/2/8_turtle/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/Занимательное программирование/2/8_turtle/gradle/wrapper/gradle-wrapper.jar b/Занимательное программирование/2/8_turtle/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/Занимательное программирование/2/8_turtle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/Занимательное программирование/2/8_turtle/gradle/wrapper/gradle-wrapper.properties b/Занимательное программирование/2/8_turtle/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d706aba --- /dev/null +++ b/Занимательное программирование/2/8_turtle/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/Занимательное программирование/2/8_turtle/gradlew b/Занимательное программирование/2/8_turtle/gradlew new file mode 100755 index 0000000..a69d9cb --- /dev/null +++ b/Занимательное программирование/2/8_turtle/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/Занимательное программирование/2/8_turtle/gradlew.bat b/Занимательное программирование/2/8_turtle/gradlew.bat new file mode 100644 index 0000000..53a6b23 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/Занимательное программирование/2/8_turtle/settings.gradle b/Занимательное программирование/2/8_turtle/settings.gradle new file mode 100644 index 0000000..74fc652 --- /dev/null +++ b/Занимательное программирование/2/8_turtle/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'core' \ No newline at end of file diff --git a/Занимательное программирование/README.txt b/Занимательное программирование/README.txt new file mode 100644 index 0000000..f07b247 --- /dev/null +++ b/Занимательное программирование/README.txt @@ -0,0 +1,9 @@ +Задания решены на разных языках программирования, но в большинстве +случаев используется язык, выбранный для примеров и в самой книге, +Pascal или Delphi, в моем случае это Free Pascal и Lazarus. + +В первой главе ("Компьютерное моделирование") есть один С файл (для +рисования применяется Cairo). + +Вторая глава ("Анимация и графические эффекты") основывается на Java +и игровом движке libGDX.