-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmMain.frm
2936 lines (2835 loc) · 124 KB
/
frmMain.frm
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Begin VB.Form frmMain
Appearance = 0 'Flat
BackColor = &H0080FF80&
BorderStyle = 0 'None
Caption = "No Rhapsody for The Weak"
ClientHeight = 3600
ClientLeft = 0
ClientTop = 0
ClientWidth = 4800
ClipControls = 0 'False
LinkTopic = "Form1"
ScaleHeight = 240
ScaleMode = 3 'Pixel
ScaleWidth = 320
StartUpPosition = 2 'CenterScreen
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\
' Castlevania : No Rhapsody for The Weak
' Main Form
' Programmed by Matt Jones
' Started on : 10/09/02
' Last update : 07/30/03
' -------------------------------------------------------------------
' GENERAL DECLARATIONS
'\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/
'--------PROGRAM NOTES--------'
'Put all loops inside functions so they don't have to be called for each check of the loop.
'Make xxxCol.txt files for the projectiles to use on weapons Alucard has hit back at foes
'Give projectile weapons 50 extra pixels to move off screen before they are destroyed
'Sinking trough platforms does not work with new state machine!
'Add spark to candle's destruction
'Add items such as hearts to itmSpr.gif so they can be grabbed from candles. Have the first
'few items pickups things like hearts & money that arent added to the inventory
'
'
'Get a good Paint program and fix three layer backgrounds!!!!!!!!!!
'Have movement code for diagnols!!!!!!!!!!!!
'Use getascii key thingy instead of keydown because it is not working with a ton of keys down.
'!!!!!!!!!!!!!!!Update sword collision file because it is outdated!!!!!!!!!!
'Add Warg character.
'Remove cape and hair from collision
'Resize collision arrays to be smaller
'Shrink State machine with < & > signs
'Replace background scrolling
'Add pushing animation
'Add remaining animations
'07/30/03-Most of the OOP translation is complete. Only minor objects
' such as projectiles and water need to be converted. More
' with statements need to be used along with the background
' changing code, and most references to (CH) need to be gone.
'07/28/03-Shrank the size of the collision arrays by using the
' ammount of lines in the text col files. Started conversion
' to OOP for much easier use of variables.
'07/24/03-Gave memScreen the value of me.hdc, and replaced me.hdc
' with memScreen to not have to refer to the object. Fixed
' error with attack animations being messed up when jump is
' pushed. Fixed error with EndRez, that stopped it from
' trying to change the resolution when the resolution was not
' changed in the begining.
'07/09/03-Greatly improved speed by having the functions that do
' movement for characters contain the loops for each
' character rather than having the function called each time
' by each character. This means that the function is only
' called once each loop, rather than once for each character
' in the loop. Started basic efects for the candles when
' destroyed. Simplified the way the game loop checked for a
' game over and the end of the program.
'07/08/03-Fixed the main loop so it would flip the buffer to the
' screen on frames that haven't been updated, rather than
' redrawing the entire buffer piece-by-piece. Fixed
' resolution changing code to actually work - Maybe.
'07/04/03-Fixed problem with items being replaced by incorrect items
' when the list of exposed items was being updated. An
' inventory array was incorrecly nested with an item array.
'07/02/03-Added real water splashing effects. It still only works
' once though. Fixed problem with items not having the right
' weight for their gravity.
'06/20/03-Fixed zombie so it hibernates when too far off the screen
' and re-spawns when Alucard is in range. Made projectile
' weapon collision detection work. Fixed error that would
' only let zombies throw projectiles when the background had
' an X of zero. Fixed error with projectile weapons being
' drawn incorrectly when facing left. Fixed error with the
' collision detection for the projectiles getting stuck on
' by not resetting the collision value. Fixed error in the
' projectile collision detection that had some left over
' arrays from the item collision detection it was copied
' from. Fixed problem with the code that delets and replaces
' projectiles weapons that updated everything but the
' direction the projectiles was traveling. This would result
' in projectiles sudenly changing direction in mid-air.
'06/17/03-Fixed problem with sub weapon animations not being replaced
' properly when an axe is deleted off the screen.
'06/16/03-Made sub weapon axes work. They can be thrown until they
' move off the screen where they are deleted. No collision
' detection, gravity, or weapon bounding(hit projectiles with
' sword, and maybe back at enemy).
'06/14/03-Made gravity for jumping. Distance moved decreases every
' time Alucard moves up. The distance is reset to normal when
' Alucard's gravity detects a collision with the ground.
'06/13/03-Fixed error where gravity would move Alucard, then when he
' started falling and using his sword for the first frame
' he would move again. Re-arranged code so collision and
' coordinates files for Items, headsup display, and Alucard
' would be loaded with the program rather than from the save
' file, because they never change.
'06/11/03-Fixed problem with the state machine letting falling
' attacks be processed when Alucard was landing. This would
' result in him getting stuck in his sword swinging
' animation. Also fixed the problem with background layer
' three and four being drawn when resetting to a save room or
' room with only one background layer.
'05/29/03-Replaced Alucards state machine. It now works mostly off of
' what button was pushed, and is faster. There are a few
' errors with jumping and sword swinging while standing.
'05/06/03-Fixed small error that had the LoadDC code deleting the
' temporary objects before it had a chance to get the image
' dimentions. This would leave the objects holding the
' dimentions in memory, causing memory leaks. Made it so
' there could be a third background layer. All that's needed
' is for the XX-X-EX.TXT files to list the images, and the
' program will take care of the rest.
'05/05/03-The sword collision file was updated to work with falling
' while slashing down and out. Fixed small error that would
' cause Alucard to only jump a few pixels high after using
' his sword in the air. It was caused by the fall sword out,
' fall sword down, and jump sword animations setting the jump
' distance to its max when they finished (In hopes that
' Alucard would not be able to jump again). Got rid of the
' separate sword animation routines, and replaced them with a
' function. Fixed error that allowed Alucard's state to be
' set to stop, while in the air. This allowed you to
' repeatedly push the direction and attack, to repeatedly
' jump and slash up in the air. Made ChangeEnemies reset the
' states and frames of animations to their starts as each is
' loaded. Fixed an error that caused the enemy movements to
' use their distance and not their space to calculate
' collisions. Made zombie character more like SOTN. It will
' spawn from a designated point, unspawn when out of range,
' and turn around if it hits walls or stairs.
'04/30/03-Added animation with Alucard having his legs held together
' while standing still. Chopped last animation off on
' standing up animation. Made teetering animation work when
' stopping instead of standing. Made still animation work
' when standing up, or landing, or stopping on surfaces that
' cause teetering. Made last three frames of the falling
' sword down and out animations stick for three frames,
' because they are too short. Added falling attacks to call
' for ActionAirHurt to eliminate breaks in hurt machine.
'04/29/03-Made ActionTurnAround set the new direction before it moved
' Alucard to fix the glitch that moved the opposite direction
' in the first frame of animation. Fixed having the wrong
' frame of animation at the begining of turning when comming
' from walking, by having the ActionTurnAround function set
' the first frame of animation to the first frame of turning
' rather than one before (because of the delay it would not
' be updated). Made turn restart when turning back-to-back in
' different directions.
'04/27/03-Jumping and falling sword animation and collision detection
' is all but perfect. There is a small error with it not
' always working when not holding the direction, and another
' when you try to jump after slashing and falling.
'04/26/03-Nearly finished the jumping and falling sword animations.
' They just need some work to align the swords to Alucard and
' make the state machines more stable.
'04/23/03-Made landing cancel out sword air out to fix sticking
' state.
'04/20/03-Fixed errors with items being in the wrong place after
' other items have been removed or added. Added jumping sword
' animation. Needs falling sword. More work should be done on
' having landing and hard landing cancel out animations.
'04/16/03-Items can now be recieved by touch and added to inventory.
' There is a glitch that swaps the placement of items when
' items are suppose to be deleted.
'04/14/03-Fixed the sprite section used for Alucard's jumping
' animation. His hair now moves more realistically. Made it
' so Alucard's collisions with items could be detected. All
' that needs to be done is for them to be erased from the
' screen and added to the inventory array.
'04/09/03-Fixed sloppy transition between turning and walking
' animation by starting the walking animation half way
' through, where the cape, hair and legs are matching.
'04/09/03-Tweaked Alucard's animations: Turning around now takes
' twice as long. Falling down through the air is now in
' alignment with the rest of sprites. His feet now touch
' the ground while walking (even though they don't in
' SOTN -- his head controlled walking alignment). Fixed
' small error with turning around having Alucard face the new
' direction before he started turning. Fixed similar error
' with jumping animation not updating the state until after
' the first delay. Replaced the form's surface as the screen
' and eliminated all remaining picture boxes. Replaced some
' VB color constants with real values for speed.
'04/07/03-Fixed problem with item collision detection. It now works
' with the correct dimensions, gravity, collision detection,
' items, and source objects. Added weight to items so they
' can fall at different speeds.
'04/06/03-Item gravity and collision detection complete. For now all
' items fall straight down. There is an error with the
' collision detection knowing the dimensions of the sprites,
' which causes collision errors.
'04/05/03-Made candles that are destroyed turn into items. Basic work
' is done. They need collision detection, falling gravity,
' and an inventory/menu to be added to and viewed from.
'04/01/03-Made it so candles and other destroyable objects could be
' wiped away with a hit of the sword. They need proper
' destruction animations and some item birth giving code when
' destroyed. The ability to use the sword in the air would
' also help greatly!
'03/25/03-Sped up the loading of images by only getting the width and
' height of the background images instead of all of them.
'03/24/03-Removed the need to use pictureboxes when loading which
' speed things up for loading and screen drawing. Also
' tweaked the sound to keep the same song, load a new one,
' or not play anything because there is no file, depending
' on what is saved in the MU.txt file.
'03/22/03-Fixed problems with large backgrounds causing slowdown.
' This was accomplished by eliminating the pictureboxes and
' loading real images directlt into the memory DCs rather
' than creating them as a virgin bitmap and then passing the
' image in.
'03/15/03-Added more rooms to the castle entrance and tweaked how
' some of them load new backgrounds.
'03/14/03-Made it so the program can eat text files that tell what
' sound effects to play for Alucard, Enemies, and the
' background music. Support for .MP3 files is needed because
' .WAV take up too much space.
'03/13/03-Added support for sound effects and music with DirectX 8.
' The code will be moved to the end of the background
' changing code and open an ENT-1-MU.txt file that points to
' the music and sound effect files to load. Fixed stupid error
' with the character's sprite being out of alignment when
' facing left. The problem was caused because I was using
' Alucard's coordinates to calculate all the characters left
' Xpos.
'03/11/03-Fixed the collision boxes for the enemy characters. They
' now will collide with the backgrounds properly. Walking
' left for all the characters is working, except for a
' strange glitch: The Xpos for mirrored sprites (facing left)
' does not have any effect on its sprite. All tests prove
' otherwise, but the error still exists.
'03/05/03-Added the BloodyZombie character and tweaked the enemy code
' to make it easier to have multiple enemies share the same
' sprites and coordinates.
'03/02/03-Fixed error where the program would continue to keep the
' same number of background layers when Restarting after a
' Game Over screen. This would create a phantom image of the
' old background, because there were blank layers being
' drawn. Scrolling of background layers is now perfect.
'02/26/03-Added beginning of the heads-up display. The health numbers
' and health bar work. Vertical scrolling of the second
' background layer is wrong.
'02/25/03-Added more backgrounds and redid the naming conventions for
' the files and images to have a common scheme.
'02/21/03-Fixed state machine to work correctly while ducking and
' attacking. This includes both downward and outward swings.
' Replaced many instances of ANI(CH) with W to speed up
' animation routines and screen drawing. Similar things were
' done through out large occurrences of nested variables.
'02/20/03-Added slashing forward while ducking animations. The
' slashing down does not work yet, but it's done.
'02/19/03-Fixed game over screen so you could start a game over from
' scratch by dumping and reloading all the variables and
' memory DCs. Made it so if you push ESC then you go straight
' to the Game Over screen. Made Alucard's outline
' transparent. Made the SCollisionDetection so it doesn't
' check for weapon collisions unless DrwWep(CH)=true. This
' eliminates some collision detection errors at close range.
'02/17/03-Added a Game Over screen. Restarting a game needs some work
' though. Tweaked moveAlucard by making it into a function and
' shrinking down some variables.
'02/15/03-Fixed minor error with damage showing on the outside of
' Alucard as a pink box, instead of over him.
'02/13/03-Worked feverishly on the memory DC problem with older
' versions of Windows(95, 98, ME). Might have fixed problem.
' Program now runs a little faster thanks to memory DCs only
' being created before the game starts and not every time
' a collision takes place. Some of the state machines were
' sped up by using small named variables in place of nested
' arrays.
'02/12/03-Changed background layer scrolling to be based on the
' position of the first background layer. As in
' BGX2 = BGX * 2 \ 3. This will insure proper placement and
' eliminate the chance of it scrolling too far in one
' direction. This also means that Alucard can move any amount
' of pixels he wants in one loop without having to move the
' same in the other direction to fix the background. Tweaked
' jumping animation to start when the delay starts. Added the
' other jumping damage animations.
'02/11/03-Removed a bunch of slow constants. Started to speed up the
' state machines by using select case. Started to speed up
' memory DC drawing by using 0 as a source and vbWhiteness
' as a dwRop. The collision images need to have their colors
' inverted for it to work though.
'02/08/03-Used getDC API call instead of frmMain.hdc to try and fix
' memory leak problem. Sped up Dir checking with Dir$.
'02/07/03-Probably finished tweaking pixel collision detection. Made
' each background have its own backgroundCh.txt file, that
' will determine character starting position, enemy count
' and which enemies are used.
'02/05/03-Started major optimizations. Used Len() instead of ="" for
' strings. Used \ instead of / for division. Replaced most
' local integer variables with long variables. Added support
' for multiple enemies. Tweaking pixel collision detection.
'02/04/03-Removed gravity, but you still hit the ground hard when
' falling from great heights, or when you get hit by an
' enemy.
'02/03/03-Fixed minor problem with enemies being out of place in the
' pixel collision detection when facing left. Fixed background
' scrolling to move the layers the same distance, as to not
' slowly move them more and more off the screen. Added zombie
' death animation. Maybe fixed the memory DC problem by having
' it select the previous object before deleting the DC.
'01/31/03-Fixed the pixel perfect collision detection. Now you can kill
' the zombie.
'01/30/03-Eliminated the need to use picture boxes for image storing.
' Memory DCs are standard now. This slightly speeds up screen
' drawing. Made Alucard bounce off a wall if an enemy hits him
' into it. This completly eliminates him getting pinned
' between a foe and a wall.
'01/29/03-Added support for background layers. They also scroll along
' the correct axis and correct distances.
'01/28/03-Fixed resolution changing problem by not using the
' SendMessage API call that it originally used. This
' would only have been necessary if we were also going to
' change the size of windows. Also fixed the problem that
' caused the pieces for the background collision's unpassable
' objects to be drawn in the wrong place if you enter the
' screen from the left. Fixed animation sticking problem when
' you jump straight up and then hold the opposite direction
' you are facing. Also fixed the sticking frames when turning
' around too fast, or holding both right and left.
'01/26/03-Fixed the background changing to work perfectly for any
' direction. More backgrounds and exit files can simply be
' plugged right into it. The memory DC seems to cause
' problems in Windows ME.
'01/25/03-Created two more frames of animation for the right and left
' jumping. This boost the number from 4 to 6 and makes it
' less repetitive when it repeats the last 4 frames in the
' end (was only 2). Fixed last frame of landing animation.
' Sped up environmental collision detection by using a memory
' DC as a scratch pad. Figured out a better way of getting the
' Left Xpos (for mirroring sprites) using the character's
' center (CC) which is always going to be the same.
' Left Xpos = CC - (Width + RightXpos - CC).
'01/23/03-Made Alucard move in a random direction when hit by an
' enemy. This will stop him from getting pinned between foes
' and walls. Also went over the code and tried to minimize
' everything and speed it up. Updated the background loader
' to not keep the previous background's objects when there
' are no new ones - moving from a background with candles and
' rocks to a background with nothing, like a save room.
'01/22/03-Added the basic hurt animations for Alucard and hooked them
' to the collision detection so they work. The collisions in
' the air only have one animation right now. Added basic
' pink coloration to Alucard when he is hurt.
'01/18/03-Fixed the soft platforms so when you jump up through them
' and land, it doesn't pull you up when you don't jump high
' enough. Fixed jumping animation's frames. Fixed ducking and
' standing animation frames.
'01/17/03-The dithering color problem was fixed. It was caused when
' the bitblt call dithered the colors in 16-Bit color mode.
' Both collision detection schemes were sped up immensely by
' by using Select Case instead of If statements. The
' background collision images were also simplified by no
' longer using orange for ledges and just letting it
' calculate that.
'01/16/03-Completed more work on background changing. Made it switch
' the backgrounds, as well as the passable and unpassable
' objects and their collisions. The permanent slowdown was
' also eliminated while changing backgrounds. The remaining
' jumping animations were also added to the straight up jump.
'01/15/03-Fixed the background scrolling and implemented a basic save
' file. Most of the other stuff involving the background
' loading was redone. The BackgroundScroll now can tell the
' difference between vertical, horizontal, or free scrolling
' backgrounds and works accordingly.
'01/13/03-Pixel collision detection is now in perfect working order.
' All it needs now is some damage animation and sprite sheets.
' Alucard Pixel collision sprite sheet finished. Developed a
' method of making them in photoshop by layering two of the
' same masks on top of each other and moving one down a
' pixel, up a pixel, right a pixel, and left a pixel. The
' exposed uderlayer is saved and the hanging-over top layer
' is removed to create a perfect outline. Added teetering
' animation to fix foot hang on ledges and staircases. Also
' added the twisting hurt animation for huge amounts of
' damage and death.
'01/10/03-Completed more work on the pixel perfect collision. Made it
' scan from left to right then move down to be faster than
' scanning up to down then moving right.
'01/09/03-Made Soft and mblnSink into Soft(CH) and mblnSink(CH) so the
' characters movements wouldnt effect the softplatform
' collisions of other characters. Added four more frames
' of animation to the candles to bring it up to 6.
'01/07/03-Moved the generation of the left Xpos and weapon collision
' detection into its own sub that is called after everything,
' but just before the screen draw. Fixed pixel perfect
' collision detection. The loop was scanning a pixel too far
' to the right and may be off by one on the left, top, or
' bottom too.
'01/04/03-Used IIF functions instead of multiple IFTHEN statements
' when inside an animation sub, to reduce the size immensely.
' Started memory DC work for the pixel perfect collision
' detection.
'01/03/03-Moved the candle state machine into the effect section. It
' is also called from the moveEffect sub with all other
' effects.
'12/30/02-Added support for platforms that you could jump through
' the bottom and land on the top, or jump while ducking and
' fall through completely.
'12/29/02-Made standing animation move on to bobbing. Made hard
' landing animation use the ending of the ducking sword
' animation. Changed other landing, jumping and standing
' animations to not skip their first frame of animation.
' Added a delay to bobbing animation to match real speed.
' Also added the same delay to zombie animation to slow it
' down.
'12/27/02-Added a hard landing code for when falling from great
' heights. It currently uses the ducking animation and then
' has Alucard stand up automatically. Also tweaked the
' collision detection to work perfectly, as long as the floor
' is at least 5 pixels thick.
'12/26/02-Simplified the code for moving right, so it would be as
' short as the code for moving left. Made all the characters
' use the same variables for their position and the same code
' for collision detection.
'12/23/02-Setup program for having all the enemy and character
' collision and variable code the same.
'12/20/02-Fixed right and left collision detection to work correctly
' and eliminated the bouncing problem when hitting varying
' height and shaped walls. Also fixed the jumping animation
' so gravity would take over when a ceiling was hit. The mask
' was also updated because the tolerance on the old one was
' off.
'12/19/02-Painstakingly redid the sword effects. Created a new method
' that will be used on all the other sword effects as a
' template, making it much easier. Also fixed the resolution
' changer and fixed an error that allowed the sword animation
' to be canceled out when any non game key was pressed, like
' a, ctrl, or f3. Also fixed the bouncing in and out of the
' sides of small protruding objects. Added a small picturebox
' to the opening screen that detects crappy video cards.
'12/18/02-Re-did most of the collision detection to be very fast. It
' now only needs to be configured to move subtle distances
' that happen when a movement is interrupted by a collision.
'12/16/02-Fixed the problem with characters sinking into the floor
' when they move up or down a flight of stairs. It works
' because it moves them regardless if there is a collision -
' because they are still standing on stairs allowing them
' to move up or down.
'12/15/02-Re-coded the collision detection to actually work from
' where the sprite is located. Also made it accurate to the
' pixel where it hits the unpassable object.
'12/12/02-Completed most work on the backgrounds' passable and
' unpassable objects, their masks and collision detection,
' candle movement, and loading and masks.
'12/11/02-Completed more work on enemy physics, sprites and AI. The
' sprite placement and some AI routines are all that need to
' be added.
'12/10/02-Fixed the sword engine so it would self terminate and
' cancel out the WEPs and drawing if the attack was
' canceled by movement. Also completed standing sword
' animation for the right and left sides. Also added some
' enemy animation. It needs the rest of Alucard's code to be
' converted and some AI.
'12/09/02-Some of the states were sticking because the sprites
' weren't changing and the states never got an opportunity
' to change. This was fixed by changing the state first.
'12/08/02-Completed mirroring of sprites. Also started to fine tune
' positions and movement.
'12/04/02-Redid sprite sheets and started fixing the animations to
' use them. Also, came up with a plan to use a mirroring
' BitBlt for the left side.
'12/02/02-Started sword animations. Also added bobbing animations and
' made is go off when Alucard is standing still or stops
' dashing instead of slamming on the breaks.
'11/25/02-Made a direction cancel-out if the opposite is pressed
' while it is still being held down. This only applies to the
' right and left for keyDown and keyUp. Also started the
' drawing of the small objects into the background such as
' candles and rocks.
'11/23/02-Fixxed the sinking into the floor by having the collision
' detection note how far stuff sinks and then add that to the
' BitBlt so it will always be right where it should. It needs
' to be used in the stairs to stop sinking all together.
'11/21/02-Sped up the collision detection by only having it work in
' the areas that are red (where Alucard is standing), instead
' of having it draw and search the entire mask.
'11/20/02-Slightly tweaked the background changing and jumping. Also
' rearranged the code to be more organized.
'11/19/02-Jumping now works. It seems a little too mechanical and
' moves in too straight a line, but is works. Also added
' ghetto support for background changing.
'11/15/02-Fixed the way the screen scrolled while moving every which
' way on the stairs. Also used a separate color for each
' type of stair case, right and left. Also started falling
' movement animations.
'11/14/02-Added support for moving up stairs that actually works.
' Walking back down them is strange though.
'11/11/02-New collision detection implemented using rectangles
' instead of pixels. It will be used for environmental
' collision. The pixel perfect collision detection will be
' reserved for Alucard VS Enemy collisions.
'10/25/02-Started jumping animation. There seems to be some
' confusion on how to pull it off. Especially the collision
' detection for the ceiling. Also tweaked the turning
' animation to use only two variables for the SetStart.
'10/24/02-Added animations and constants for standing up for the
' right and left sides.
'10/22/02-Added a falling and landing animation for the left and
' right sides. Also added landing states and the current
' state is now visible in the caption of the collision form.
'10/19/02-Slightly modified the drawing routines and did some speed
' tests. The CreateDIBitmat and GetDIBitmatTemplate code
' will speed things up immensely. Hurry up and implement them.
' Collision detection was also tweaked. It works a lot better
' with smaller masks and smooth black areas on both of the
' masks. Also smoothed out Alucard's masks by having his hair
' and cape a dark gray instead up black.
'10/18/02-Implemented vertical scrolling, both up and down. Gravity
' now works. As does the collision detection of the floor.
' There are some problems with the size and shapes of the
' background masks that cause hang-ups though.
'10/15/02-Added ducking animations for the right and left. Added all
' the resolution changing code, but it isn't in use because
' it is not working correctly. A better background BitBlt is
' now being used. It May cause problems though.
'10/14/02-Added the stopping animation. Updated the SetStart code so
' if the numbers aren't any of the ones used for the
' animations they are dumped and replaced by zero.
'10/11/02-Collision detection was speed up considerably by only
' having it run the CollisionDetect function when the screen
' or Alucard scrolls. Also had to move masks to their forward
' three pixels so the cape wouldnt catch on the walls.
'10/10/02-Picture boxes and basic code for the collision detection
' are now complete. More basic movement added--dashing right
' and left, walking left and right and turning around from
' both sides is now complete.
'10/09/02-Started basic screen drawing routines and sheet loaders.
' Transferred most of the salvageable code and fixed it up to
' work more efficiently over here. Some basic movement has
' been completed without the use of those damn timers.
'--------FUTURE WORK NOTES--------'
'Make the background mask smaller so it cant scroll up any more. Also
' still have it big enough so the floor is seven pixels thick.
'Use a mask of Alucard that has a gray cape to give his cape a
' transparent effect rather than the psx's flashing (only
' when he has The Green Semi-Transparent Cape).
'Try to get rid of any state setting inside anything that isn't an
' ActionMovementDirection procedure, or it will be a
' nightmare later on.
'-------GLITCH LOG--------'
'----BROKEN----'
'1.If you jump through a soft platform and land on another soft
' platform, you will fall right through it. This is because
' the collision detection is turned off when falling through a
' soft platform and then reactivated when landing on a hard
' one. This also means that if you pass through a soft platform
' while walking, it will deactivate the collision detection
' causing you to fall until you are out of its range.
'----FIXED----'
'1.When you get close to a wall, you can repeatedly push the same
' button to hump your way through it one pixel at a time.
' FIX:The problem was that the ANI was not being reset
' until after the first collision detection. It was
' scanning a 0 x 0 size grid and not doing anything until
' the SetStart function was run, just after the first
' collision detection.
'2.When you try to move while falling, the state sticks in the last
' direction you were facing when you hit the last frame of
' falling animation.
' FIX:This was fixed by having the state set before ANI
' was updated, so it would no longer depend on the value of
' ANI - to get inside the if statement -, only if the
' animation was called.
'3.If you turn in the opposite direction really fast, or push the
' opposite direction down while still holding the original
' button, the animations will stick.
' Fix:The turning animation included the walking animation's
' frame numbers in the SetState. This caused it to not update
' the frame, but update everything else.
Option Explicit
'Dim lngSound As Long
Dim DrawMenu As Boolean
Dim GameOver As Boolean
Dim mblnItems As Boolean ' Items print to screen
Dim ItemLoop As Long ' Used in itrem drawing loop
'Dim FR As Long ' Frame Rate
'Dim F1 As Long, F2 As Long ' Frame Timmer
'/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\
' GENERAL DECLARATIONS
' -------------------------------------------------------------------
' FORM LOAD
'\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/
Private Sub Form_Load()
Me.Show
SavePicture frmChangeRez.picScreenBox.Image, App.Path & "\Backgrounds\blank.bmp"
memScreen = Me.hdc
memBlank = LoadDC("", False)
memBuffer = LoadDC("", False) ' Create Buffer
memCollEnv = LoadDC("", False) ' Create Enviornmental Collision Buffer
memCollCh = LoadDC("", False) ' Create Character Collision Buffer
'Set DX = New DirectX8 ' Make DirectX 8 Available
'Set DS = DX.DirectSoundCreate("") ' Make Sound Available
'DS.SetCooperativeLevel hwnd, DSSCL_NORMAL ' Standard Sound
CH = 0 ' Alucard
Player.STA = STANDRIGHT
Me.Show
LoadRequiredSprites
LoadUpSprites
UpdateBackgroundCollision
LoadNextBackground
Me.SetFocus
End Sub
'/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\
' FORM LAOD
' -------------------------------------------------------------------
' MAIN ENGINE
'\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/
Sub GameLoop()
Dim T1 As Long, T2 As Long
Dim AC As Boolean ' Animations complete
Do Until GameOver = True
T1 = GetTickCount()
'If FR = 0 Then F1 = GetTickCount()
Do Until T2 - T1 >= DELAY
If AC = False Then ' Redraw The Buffer
'All Animations
MoveEnemy
CH = 0 ' Alucard
MoveAlucard Player.STA, Player.ANI
CheckBackground
FinalCalculations
AC = True
DrawScreen
Else ' Flip The Buffer
BitBlt memScreen, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBuffer, 0, 0, &HCC0020 ' SRCCOPY
End If
T2 = GetTickCount()
'If FR < 3000 Then FR = FR + 1
DoEvents
Loop
'F2 = GetTickCount()
'If F2 - F1 > 1000 Then FR = 0
AC = False
Loop
If GameOver = True Then
GameOverScreen
End If
End Sub
Private Sub DrawScreen()
Dim Obj As Long, W As Long, P As Long, H As String, DW As Long, T As Long
'Dim R1 As Long, R2 As Long ' Total & Free Memory
'Dim T1 As Long, T2 As Long
'T1 = GetTickCount()
'Clear buffer
If BgLayer(2) = False Or BgLayer(3) = False Then BitBlt memBuffer, 0, 0, 320, 240, memBuffer, 0, 0, &H440328 ' SRCERASE
'Draw Layer 3
If BgLayer(3) = True Then
BitBlt memBuffer, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBgSpr3, -BgX3, -BgY3, &HCC0020 ' SRCCOPY
BitBlt memBuffer, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBgMsk3, -BgX2, -BgY2, &H8800C6 ' SRCAND
End If
'Draw Layer 2
If BgLayer(2) = True Then
BitBlt memBuffer, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBgSpr2, -BgX2, -BgY2, &HEE0086 ' SRCPAINT
BitBlt memBuffer, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBgMsk2, -BgX, -BgY, &H8800C6 ' SRCAND
End If
'Draw Layer 1
BitBlt memBuffer, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBgSpr, -BgX, -BgY, &HEE0086 ' SRCPAINT
'Draw passable background objects
For Obj = 1 To TotlCand
BitBlt memBuffer, BgX + PsXpos(Obj), BgY + PsYpos(Obj), PsWp(Obj), PsHp(Obj), memBgPsMsk, PsXp(mintCandle), PsYp(mintCandle), &H8800C6 ' SRCAND
BitBlt memBuffer, BgX + PsXpos(Obj), BgY + PsYpos(Obj), PsWp(Obj), PsHp(Obj), memBgPsSpr, PsXp(mintCandle), PsYp(mintCandle), &HEE0086 ' SRCPAINT
Next
'Draw Enemies
For CH = 1 To TotlEn
With Enemy(CH)
T = .EType
W = .ANI
If .pLeft = True Then
StretchBlt memBuffer, .PX + .LXP + EWidthp(W, T) + BgX, .PY + EYpos(W, T) + BgY, -EWidthp(W, T), EHeightp(W, T), memEMsk(T), EXp(W, T), EYp(W, T), EWidthp(W, T), EHeightp(W, T), &H8800C6 ' SRCAND
StretchBlt memBuffer, .PX + .LXP + EWidthp(W, T) + BgX, .PY + EYpos(W, T) + BgY, -EWidthp(W, T), EHeightp(W, T), memESpr(T), EXp(W, T), EYp(W, T), EWidthp(W, T), EHeightp(W, T), &HEE0086 ' SRCPAINT
Else
StretchBlt memBuffer, .PX + EXpos(W, T) + BgX, .PY + EYpos(W, T) + BgY, EWidthp(W, T), EHeightp(W, T), memEMsk(T), EXp(W, T), EYp(W, T), EWidthp(W, T), EHeightp(W, T), &H8800C6 ' SRCAND
StretchBlt memBuffer, .PX + EXpos(W, T) + BgX, .PY + EYpos(W, T) + BgY, EWidthp(W, T), EHeightp(W, T), memESpr(T), EXp(W, T), EYp(W, T), EWidthp(W, T), EHeightp(W, T), &HEE0086 ' SRCPAINT
End If
End With
Next
'Draw Alucard
With Player
CH = 0 'Alucard
W = .ANI
If .pLeft = True Then
StretchBlt memBuffer, .PX + .LXP + .Widthp(W), .PY + .Ypos(W), -.Widthp(W), .Heightp(W), .memMsk, .Xp(W), .Yp(W), .Widthp(W), .Heightp(W), &H8800C6 ' SRCAND
If .HURT = True Then StretchBlt memBuffer, .PX + .LXP + .Widthp(W), .PY + .Ypos(W), -.Widthp(W), .Heightp(W), .memHurt, .Xp(W), .Yp(W), .Widthp(W), .Heightp(W), &HEE0086 ' SRCPAINT
StretchBlt memBuffer, .PX + .LXP + .Widthp(W), .PY + .Ypos(W), -.Widthp(W), .Heightp(W), .memSpr, .Xp(W), .Yp(W), .Widthp(W), .Heightp(W), &HEE0086 ' SRCPAINT
Else
StretchBlt memBuffer, .PX + .Xpos(W), .PY + .Ypos(W), .Widthp(W), .Heightp(W), .memMsk, .Xp(W), .Yp(W), .Widthp(W), .Heightp(W), &H8800C6 ' SRCAND
If .HURT = True Then StretchBlt memBuffer, .PX + .Xpos(W), .PY + .Ypos(W), .Widthp(W), .Heightp(W), .memHurt, .Xp(W), .Yp(W), .Widthp(W), .Heightp(W), &HEE0086 ' SRCPAINT
StretchBlt memBuffer, .PX + .Xpos(W), .PY + .Ypos(W), .Widthp(W), .Heightp(W), .memSpr, .Xp(W), .Yp(W), .Widthp(W), .Heightp(W), &HEE0086 ' SRCPAINT
End If
'Draw Alucard's effects
If .DrwWep = True And .pLeft = True Then
StretchBlt memBuffer, .PX + .SXP + .WepW(.WEP), .PY + .WepYpos(.WEP), -.WepW(.WEP), .WepH(.WEP), .memWepMsk, .WepX(.WEP), .WepY(.WEP), .WepW(.WEP), .WepH(.WEP), &H8800C6 ' SRCAND
StretchBlt memBuffer, .PX + .SXP + .WepW(.WEP), .PY + .WepYpos(.WEP), -.WepW(.WEP), .WepH(.WEP), .memWepSpr, .WepX(.WEP), .WepY(.WEP), .WepW(.WEP), .WepH(.WEP), &HEE0086 ' SRCPAINT
ElseIf .DrwWep = True And .pLeft = False Then
StretchBlt memBuffer, .PX + .WepXpos(.WEP), .PY + .WepYpos(.WEP), .WepW(.WEP), .WepH(.WEP), .memWepMsk, .WepX(.WEP), .WepY(.WEP), .WepW(.WEP), .WepH(.WEP), &H8800C6 ' SRCAND
StretchBlt memBuffer, .PX + .WepXpos(.WEP), .PY + .WepYpos(.WEP), .WepW(.WEP), .WepH(.WEP), .memWepSpr, .WepX(.WEP), .WepY(.WEP), .WepW(.WEP), .WepH(.WEP), &HEE0086 ' SRCPAINT
End If
End With
'Draw Items
For Obj = 1 To TotlItm
BitBlt memBuffer, BgX + IXpos(Obj), BgY + IYpos(Obj), IWp(ItmType(Obj)), IHp(ItmType(Obj)), memItmMsk, IXp(ItmType(Obj)), IYp(ItmType(Obj)), &H8800C6 ' SRCAND
BitBlt memBuffer, BgX + IXpos(Obj), BgY + IYpos(Obj), IWp(ItmType(Obj)), IHp(ItmType(Obj)), memItmSpr, IXp(ItmType(Obj)), IYp(ItmType(Obj)), &HEE0086 ' SRCPAINT
Next
'Draw Projectiles & Sub Weapons
For Obj = 1 To TotlSub
With Enemy(Obj)
W = .SWEP
If .wLeft = True Then
StretchBlt memBuffer, BgX + .WX + .WXP + EWepW(W), BgY + .WY + EWepYpos(W), -EWepW(W), EWepH(W), memSubMsk, EWepX(W), EWepY(W), EWepW(W), EWepH(W), &H8800C6 ' SRCAND
StretchBlt memBuffer, BgX + .WX + .WXP + EWepW(W), BgY + .WY + EWepYpos(W), -EWepW(W), EWepH(W), memSubSpr, EWepX(W), EWepY(W), EWepW(W), EWepH(W), &HEE0086 ' SRCPAINT
ElseIf .wLeft = False Then
BitBlt memBuffer, BgX + .WX + EWepXpos(W), BgY + .WY + EWepYpos(W), EWepW(W), EWepH(W), memSubMsk, EWepX(W), EWepY(W), &H8800C6 ' SRCAND
BitBlt memBuffer, BgX + .WX + EWepXpos(W), BgY + .WY + EWepYpos(W), EWepW(W), EWepH(W), memSubSpr, EWepX(W), EWepY(W), &HEE0086 ' SRCPAINT
End If
End With
Next
'Draw Effects
CH = 0
If pblnDrawSplash(CH) = True Then
BitBlt memBuffer, EfctX(CH) + BgX + PsXpos(AniEfct(CH)), EfctY(CH) + BgY + PsYpos(AniEfct(CH)), PsWp(AniEfct(CH)), PsHp(AniEfct(CH)), memBgPsMsk, PsXp(AniEfct(CH)), PsYp(AniEfct(CH)), &H8800C6 ' SRCAND
BitBlt memBuffer, EfctX(CH) + BgX + PsXpos(AniEfct(CH)), EfctY(CH) + BgY + PsYpos(AniEfct(CH)), PsWp(AniEfct(CH)), PsHp(AniEfct(CH)), memBgPsSpr, PsXp(AniEfct(CH)), PsYp(AniEfct(CH)), &HEE0086 ' SRCPAINT
End If
'Draw Un-Passable background objects
For Obj = 1 To TotlUp
BitBlt memBuffer, BgX + UpXpos(Obj), BgY + UpYpos(Obj), UpWp(Obj), UpHp(Obj), memBgUpMsk, UpXp(Obj), UpYp(Obj), &H8800C6 ' SRCAND
BitBlt memBuffer, BgX + UpXpos(Obj), BgY + UpYpos(Obj), UpWp(Obj), UpHp(Obj), memBgUpSpr, UpXp(Obj), UpYp(Obj), &HEE0086 ' SRCPAINT
Next
'Draw Headsup Display
For Obj = 1 To 3
If Obj = 3 Then DW = HWidth(Head(Obj)) * (Player.HP / Player.MaxHP) Else DW = HWidth(Head(Obj)) ' Bar width
BitBlt memBuffer, HXpos(Head(Obj)), HYpos(Head(Obj)), DW, HHeight(Head(Obj)), memHeadMsk, HXp(Head(Obj)), HYp(Head(Obj)), &H8800C6 ' SRCAND
BitBlt memBuffer, HXpos(Head(Obj)), HYpos(Head(Obj)), DW, HHeight(Head(Obj)), memHeadSpr, HXp(Head(Obj)), HYp(Head(Obj)), &HEE0086 ' SRCPAINT
Next
'Draw Headsup Numbers
H = Player.HP
Select Case Len(H)
Case 1: P = 39
Case 2: P = 35
Case 3: P = 31
Case Is >= 4: P = 28
End Select
For Obj = 4 To HeadCount
BitBlt memBuffer, P, 36, HWidth(Head(Obj)), HHeight(Head(Obj)), memHeadMsk, HXp(Head(Obj)), HYp(Head(Obj)), &H8800C6 ' SRCAND
BitBlt memBuffer, P, 36, HWidth(Head(Obj)), HHeight(Head(Obj)), memHeadSpr, HXp(Head(Obj)), HYp(Head(Obj)), &HEE0086 ' SRCPAINT
P = P + 7
Next
' Show Items - Uses mblnItems in keydown event
If mblnItems = True Then
For ItemLoop = 1 To 10
Me.CurrentX = 0
Me.CurrentY = 0
Me.Font.Name = "Verdana"
Me.Font.Size = 7
Me.ForeColor = vbGreen
For Obj = 1 To 20
Me.Print "Type " & Obj; " Count " & Inven(Obj)
Next
Next
End If
BitBlt memScreen, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBuffer, 0, 0, &HCC0020 ' SRCCOPY
' Draw Collision Box
'Me.Line (BL(0) + PX(0), BT(0) + PY(0))-(BW(0) + PX(0), BH(0) + PY(0)), vbBlue, B
'View Array
'For intType = 1 To 2
' For intAnim = 1 To 20
' Debug.Print intType; intAnim; EXpos(intAnim, intType); EYpos(intAnim, intType); EXp(intAnim, intType); EYp(intAnim, intType); EWidthp(intAnim, intType); EHeightp(intAnim, intType)
' Next
'Next
'Show Memory Usage
''GlobalMemoryStatus memInfo
''R1 = memInfo.dwTotalPhys
''R2 = memInfo.dwAvailPhys
''With Me
'' .Font.Name = "Verdana"
'' .ForeColor = 65280
'' .FontSize = 20
'' .CurrentX = 10
'' .CurrentY = 10
''End With
''Me.Print R1 - R2
'T2 = GetTickCount()
'Debug.Print T2 - T1; "Draw Screen"
'Debug.Print TotlCand
'Debug.Print totlen
'Debug.Print TotlUp
'Debug.Print HeadCount
'Debug.Print PX(0)
End Sub
'Private Sub FlipScreen()
' BitBlt memScreen, 0, 0, SCREENWIDTH, SCREENHEIGHT, memBuffer, 0, 0, &HCC0020 ' SRCCOPY
'End Sub
'/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\
' MAIN ENGINE
' -------------------------------------------------------------------
' KEYDOWN AND KEYUP
'\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'If KeyCode = vbKeyRight Or KeyCode = vbKeyLeft Or KeyCode = vbKeyUp Or KeyCode = vbKeyDown Then
' mblnAttack = False 'Gives new movement priority over attacks
'End If
Select Case KeyCode
Case vbKey0: DELAY = 35
Case vbKey1: DELAY = 1000
Case vbKey2: DELAY = 2000
Case vbKey3: DELAY = 3000
Case vbKey4: DELAY = 4000
Case vbKey5: DELAY = 5000
Case vbKey9: DELAY = 0
Case vbKeyEscape
GameOver = True 'mblnEndProgram = True
Case vbKeyRight
mblnRight = True
mblnLeft = False
Case vbKeyLeft
mblnLeft = True
mblnRight = False
Case vbKeyDown
mblnDown = True
Case vbKeyZ
If mblnAttack = False Then mblnUp = True
Case vbKeyX
mblnAttack = True
mblnUp = False
Case vbKeyM ' Print items to screen
If mblnItems = True Then
mblnItems = False
Else
mblnItems = True
End If
End Select
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
With Player
Select Case KeyCode
Case vbKeyRight
If mblnRight = True Then
mblnRight = False
ResetTurn
If .pLeft = False Then
If .STA <> JUMPRIGHT And .STA <> FALLRIGHT And .STA <> LANDRIGHT And .STA <> FALLMOVERIGHT And .STA <> FALLLEFT And .STA <> LANDLEFT And .STA <> FALLMOVELEFT And .STA <> DASHRIGHT And .STA <> ATTACKDOWNRIGHT And .STA <> DUCKRIGHT And .STA <> JUMPATTACKRIGHT And .STA <> FALLATTACKRIGHT Then
.STA = STOPRIGHT
End If
End If
End If
Case vbKeyLeft
If mblnLeft = True Then
mblnLeft = False
ResetTurn
If .pLeft = True Then
If .STA <> JUMPLEFT And .STA <> FALLRIGHT And .STA <> LANDRIGHT And .STA <> FALLMOVERIGHT And .STA <> FALLLEFT And .STA <> LANDLEFT And .STA <> FALLMOVELEFT And .STA <> DASHLEFT And .STA <> ATTACKDOWNLEFT And .STA <> DUCKLEFT And .STA <> JUMPATTACKLEFT And .STA <> FALLATTACKLEFT Then
.STA = STOPLEFT
End If
End If
End If
Case vbKeyDown
mblnDown = False
Case vbKeyZ
mblnUp = False
.JT = 0
If .STA = JUMPRIGHT And .pLeft = False Then
.STA = FALLRIGHT
ElseIf .STA = JUMPLEFT And .pLeft = True Then
.STA = FALLLEFT
End If
End Select
End With
End Sub
'/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\
' KEYDOWN AND KEYUP
' -------------------------------------------------------------------
' ALUCARD MOVEMENT
'\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/
Private Function ActionWalk(W As Long) As Long
'Dash 26 to 40
'Walk 41 to 56
With Player
.Grav = 0
If W < 25 Or W > 56 Then W = 25
If .pLeft = True Then
MoveLeft DISTANCE, SPACE
Else
MoveRight DISTANCE, SPACE
End If
If W >= 25 And W < 41 Then
.STA = IIf(.pLeft = True, DASHLEFT, DASHRIGHT)
W = W + 1
ElseIf W >= 41 And W < 56 Then
.STA = IIf(.pLeft = True, WALKLEFT, WALKRIGHT)
W = W + 1
ElseIf W = 56 Then
W = 41
End If
'Debug.Print "Walk"; W; pLeft(CH)
End With
End Function
Private Function ActionTurnAround(W As Long, NewL As Boolean) As Long
'Turn 57 to 66
With Player
.Grav = 0
If .pLeft <> NewL Or (W < 56 Or W > 66) Then W = 57 ' Direction is checked to restart turn when changing direction while turning.
.pLeft = NewL ' Set New Direction
If .pLeft = True Then
MoveLeft DISTANCE, SPACE
Else
MoveRight DISTANCE, SPACE
End If
If .AniDelay >= 1 Then
.AniDelay = 0
If W >= 56 And W <= 65 Then
.STA = IIf(.pLeft = True, TURNLEFT, TURNRIGHT)
W = W + 1
ElseIf W = 66 Then
W = 49 ' Middle Of Walking
.STA = IIf(.pLeft = True, WALKLEFT, WALKRIGHT)
End If
Else
.AniDelay = .AniDelay + 1
End If
'Debug.Print "Turn"; W; pLeft(CH)
End With
End Function
Private Function ActionStop(W As Long) As Long
'Stop 67 to 79
With Player
.Grav = 0
If W < 66 Or W > 79 Then W = 66
If W >= 66 And W <= 77 Then
W = W + 1
ElseIf W = 78 Then
.STA = IIf(.pLeft = True, STANDLEFT, STANDRIGHT)
W = W + 1
End If
'Debug.Print "Stop"; W; pLeft(CH)
End With
End Function
Private Function ActionDuck(W As Long) As Long
'Duck 2 to 14
With Player
.Grav = 0
If W < 1 Or W > 15 Then W = 1
If W >= 1 And W < 13 Then
.STA = IIf(.pLeft = True, DUCKLEFT, DUCKRIGHT)
W = W + 1
End If
'Debug.Print "Duck"; W; pLeft(CH); STA(CH)
End With