-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
240 lines (216 loc) · 15.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html lang="en">
<head>
<title>MobLib Docs</title>
<!-- Meta -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="favicon.ico">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<!-- FontAwesome JS -->
<script defer src="https://use.fontawesome.com/releases/v5.7.2/js/all.js" integrity="sha384-0pzryjIRos8mFBWMzSSZApWtPl/5++eIfzYmTgBBmXYdhvxPc+XcFEk+zJwDgWbP" crossorigin="anonymous"></script>
<!-- Global CSS -->
<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">
<!-- Plugins CSS -->
<link rel="stylesheet" href="assets/plugins/prism/prism.css">
<link rel="stylesheet" href="assets/plugins/elegant_font/css/style.css">
<!-- Theme CSS -->
<link id="theme-style" rel="stylesheet" href="assets/css/styles.css">
</head>
<body class="body-purple">
<div class="page-wrapper">
<!-- ******Header****** -->
<header id="header" class="header">
<div class="container">
<div class="branding">
<h1 class="logo">
<a href="index.html">
<span aria-hidden="true" class="icon_documents_alt icon"></span>
<span class="text-highlight">MOBLIB</span><span class="text-bold">Docs</span>
</a>
</h1>
</div><!--//branding-->
</div><!--//container-->
</header><!--//header-->
<div class="doc-wrapper">
<div class="container">
<div id="doc-header" class="doc-header text-center">
<h1 class="doc-title"><i class="icon fa fa-paper-plane"></i> Quick Start</h1>
<div class="meta"><i class="far fa-clock"></i> Last updated: March 27th, 2019</div>
</div><!--//doc-header-->
<div class="doc-body row">
<div class="doc-content col-md-9 col-12 order-1">
<div class="content-inner">
<!--//doc-section-->
<section id="installation-section" class="doc-section">
<h2 class="section-title">Installation</h2>
<div id="step1" class="section-block">
<h3 class="block-title">Step One</h3>
<p>Add the JitPack Repository to your build path</p>
<p>In your builde.gradle (Project: project_name)</p>
<pre>
<code class="language-markup">
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
</code>
</pre>
</div><!--//section-block-->
<div id="step2" class="section-block">
<h3 class="block-title">Step Two</h3>
<p>Add The Dependency</p>
<p>This time in your builde.gradle (Module:app)</p>
<pre>
<code class="language-markup">
dependencies {
...
implementation 'com.github.e-mobadara:moblib:v1.2.3'
}
</code>
</pre>
<p><br/>
It is good to have the <a href="https://github.com/e-mobadara/2d-game-lib">Repository</a> as watched to get notified about new Releases
</p>
</div><!--//section-block-->
<div id="end_install" class="section-block">
<h3 class="block-title">That's It!
Now You are Good to Go</h3>
</div><!--//section-block-->
</section><!--//doc-section-->
<section id="philosophy-section" class="doc-section">
<h2 class="section-title">Philosophy</h2>
<div class="section-block">
<p>
The most important class in this library is AndroidGame.<br/>
It extends Activity and implements Game.<br/>
AndroidGame is the One responsible for what screen is showing at the moment.<br/>
Each Screen is responsible for the sprites that are showing. <br/>
Screen have an ArrayList of sprites, and in order for a sprite to be shown it has to be added to this List.<br/>
</p>
<p>The current Image says it all</p>
<img class="img-fluid" src="assets/images/explication/philosophy.png">
</section><!--//doc-section-->
<section id="tuto" class="doc-section">
<h2 class="section-title" id="first-game">Your First Game</h2>
<div class="section-block">
<p>We will create our first Game to get you started on using MobLib
</p>
<p>Create a new Project as you usually do and have the First Acitivity as an Empty Activity<br/>
You should end up with something like this </p>
<img class="img-fluid" src="assets/images/tutorial/step1.png">
</div>
<div class="section-block">
<p>Now, let's add The Dependencies as described in the installation section </p>
<img class="img-fluid" src="assets/images/tutorial/step2.png">
<p></p>
<img class="img-fluid" src="assets/images/tutorial/step3.png">
<p>Now, Hit sync now and the library should be installed in this project</p>
</div>
<div class="section-block" id="adding-android-game">
<h3 class="block-title" >Adding the AndroidGame</h3>
<p>Let's change the code of the GameActivity so that it will extend from AndroidGame</p>
<p>move the cursor to the end and Press alt+enter to implement the required methods, Make sure you are choosing getInitScreen</p>
<img class="img-fluid" src="assets/images/tutorial/step4.png">
<p>If everything went okay you should end up with something like this</p>
<img class="img-fluid" src="assets/images/tutorial/step5.png">
<p>The Screen That the AndroidGame uses Should not be null so let's create a Screen class</p>
</div>
<div class="section-block" id="create-your-screen">
<h3 class="block-title">Creating Your Screen</h3>
<p>
Create a new Class, Call it what ever you want, and make it extends Screen. Implement the required functions and consctructor
</p>
<img class="img-fluid" src="assets/images/tutorial/step6.png">
<p><br/>Now Go back to your AndroidGame Activity and have the getInitScreen return your new Screen</p>
<img class="img-fluid" src="assets/images/tutorial/step8.png">
<p>By now, You have a Game that will have a black screen, Let's add a sprite to it</p>
</div>
<div class="section-block" id="create-your-sprite">
<h3 class="block-title">Creating the Sprite</h3>
<p>Create a new Class and have it extend from Sprite, implement the consctructor</p>
<img class="img-fluid" src="assets/images/tutorial/step9.png">
<p>As you see, For the sprite to be initialized, it has to have an Image. as a good practice we keep these images and assets <br/>
as public static variables that can be initialized once and be refered to anytime</p>
</div>
<div class="section-block" id="assets">
<h3 class="block-title">Assets</h3>
<p>Create a class and put your public static variables that will refere to the ressources your app will be using </p>
<img class="img-fluid" src="assets/images/tutorial/step10.png">
<p><br/>Let's make this Image refer to the image I did put in res/drawable folder</p>
Return to the AndroiGame Class and before your Screen uses the sprite let's initialize the Image first.
<img class="img-fluid" src="assets/images/tutorial/step11.png">
</div>
<div class="section-block" id="sprite-to-screen">
<h3 class="block-title">Adding sprites to the screen</h3>
<p>Let's Go to our Screen and add the Sprite<br/>
1- make a private variable that will hold our sprite <br/>
2- initialize the sprite in the consctructor<br/>
3- Make the Sprite Draggable by setting it to a non static Sprite, because all Sprites are static by default<br/>
4- Then add the sprite the The ArralList of the Screen using <code>addSprite(sprite)</code>
<img class="img-fluid" src="assets/images/tutorial/step12.png">
now Run your game
</p>
Results:
<img class="img-fluid" src="assets/images/tutorial/finally.png">
</div>
<p>
The Image keeps repeating itself because there is no background, You can stop that by adding <br/>
<code>game.getGraphics().drawARGB(256,0,0,0);</code> in your render method.<br/>
You dont have to worry about it if you have a background.
</p>
</section><!--//doc-section-->
<section id="examples" class="doc-section">
<h2 class="section-title">Examples</h2>
Now That You made this game, You must have the required knowledge to Get inspired and understand the games that we have made
<br/> Check <a href="https://github.com/e-mobadara">e-mobadara repositories</a>
<h3>Remember! You can always ctr+leftClick on a Class to see its javaDoc. Most of them have it by now</h3>
</section>
</div><!--//content-inner-->
</div><!--//doc-content-->
<div class="doc-sidebar col-md-3 col-12 order-0 d-none d-md-flex">
<div id="doc-nav" class="doc-nav">
<nav id="doc-menu" class="nav doc-menu flex-column sticky">
<a class="nav-link scrollto" href="#installation-section">Installation</a>
<nav class="doc-sub-menu nav flex-column">
<a class="nav-link scrollto" href="#step1">Step One</a>
<a class="nav-link scrollto" href="#step2">Step Two</a>
<a class="nav-link scrollto" href="#end_install">That's it</a>
</nav><!--//nav-->
<a class="nav-link scrollto" href="#philosophy-section">Philosophy</a>
<a class="nav-link scrollto" href="#tuto">Your First Game</a>
<nav class="doc-sub-menu nav flex-column">
<a class="nav-link scrollto" href="#adding-android-game">Adding The AndroidGame</a>
<a class="nav-link scrollto" href="#create-your-screen">Creating Your Screen</a>
<a class="nav-link scrollto" href="#create-your-sprite">Creating the Sprite</a>
<a class="nav-link scrollto" href="#assets">Assets</a>
<a class="nav-link scrollto" href="#sprite-to-screen">Adding the Sprite to the Screen</a>
</nav>
<a class="nav-link scrollto" href="#examples">Examples</a>
</nav><!--//doc-menu-->
</div>
</div><!--//doc-sidebar-->
</div><!--//doc-body-->
</div><!--//container-->
</div><!--//doc-wrapper-->
</div><!--//page-wrapper-->
<footer id="footer" class="footer text-center">
<div class="container">
<!--/* This template is released under the Creative Commons Attribution 3.0 License. Please keep the attribution link below when using for your own project. Thank you for your support. :) If you'd like to use the template without the attribution, you can buy the commercial license via our website: themes.3rdwavemedia.com */-->
<small class="copyright">Designed with <i class="fas fa-heart"></i> by <a href="https://themes.3rdwavemedia.com/" target="_blank">Xiaoying Riley</a> for developers</small>
</div><!--//container-->
</footer><!--//footer-->
<!-- Main Javascript -->
<script type="text/javascript" src="assets/plugins/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/plugins/prism/prism.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-scrollTo/jquery.scrollTo.min.js"></script>
<script type="text/javascript" src="assets/plugins/stickyfill/dist/stickyfill.min.js"></script>
<script type="text/javascript" src="assets/js/main.js"></script>
</body>
</html>